I am working on this project in Drupal 8, parking management system. I have the admin populating the parking slots available in the building. Then an anonymous user visits the site, puts their details and those of their car, and then in drop down selects a parking slot. The parking slots are an entity reference fetched from what the admin populated. How do I make the system dynamically populate this dropdown so that the user only sees the empty slots? Like after they book slot A, I want it to disappear so that the next person booking does not see it in the dropdown list of available slots. This is to avoid two or more people booking the same slot. If there is a module that does this please send me a link

Comments

Nahasean’s picture

I have found a way to filter the items displayed in the drop down. Iadded a default field when creating a parking slot which is a boolean called 'available', whose default value is 'on'. Then I used entity reference display mode to filter and get only those parking slots whose available value is 'on'. So now I have managed to only display the empty slots in the database. What is remaining is find a way to change the boolean value of the selected parking slot to 'off' so that the next person does not see it in the drop down because it will be filtered out. I think one way to do it is to edit the query that saves the form's data to also go and change the available option of this parking slot to 'off'. Any Idea how to get hold of that query and edit it?