Cascading Dropdowns in a Modal Form #16116
Unanswered
Exitalterego
asked this question in
Help
Replies: 0 comments
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
Hi all,
TLDR - how can I get a modal form to load a single records field values and then cascade two dropdown menus?
I'm attempting to set up a couple of cascading dropdowns inside a form inside a modal popup and have hit a number of problems that are most likely being caused by my own ignorance, so I'm hoping someone can point out what I am doing wrong.
Goal: Have an edit button in a table open a modal popup containing a form for editing that records field values. Two of the fields are single select dropdowns where the value of one is tied to the value of the other. In my case the first assigns an asset category (Computing Devices, Storage Devices, Network Hardware etc) with the second being a subtype (switch, router, wireless access point etc)
Environment: self hosted Docker instance running BB 3.10.5
Attempt 1:


I have tried to achieve my goal by using a form block. The edit button from the table saves the row id to {{ State.row_id }} (note I'm using the primary key numerical id, not the URL friendly _id) and then opens the modal. Inside the modal is a data provider with a form block nested inside it.
The form block has the main table listed as its data provider, is set to update and has the row id being passed with the above state binding. This all works as intended.
Inside the form are two single-select dropdown fields; asset_category and asset_subtype. The first, asset_category, has two actions set to its On Change property. One, it saves its own value to {{ State.asset_category }} using {{ [New Form Block].Fields.asset_category }}. Two, it refreshes the previously mentioned data provider.
This data provider reads from a table linking asset_category to asset_subtype and then has a filter based on {{ State.asset_category }}.


I assumed that doing things this way would see the filter on the data provider being updated/refreshed every time the first dropdown was changed, and the second dropdown would then be able to show these options when clicked. What actually happens is that there is a lag between the selection of the category and the sub-types being updated. For example, if I select category 1, I won't see any sub-types. Selecting category 2 will then show the sub-types associated with category 1 etc.
Attempt 2:
As using a form block didn't create the desired result, I switched to using the standard form component instead, given that the tutorial here seems to be exactly what I am looking for. However, in this case I don't seem to be able to get any data passed to the form from the relevant record.
I tried setting up a View as the data source for the form, filtered using {{ State.row_id }}, but that didn't work (I assume because states are not accessible via bindings in the back end?). I also tried nesting the form in a data provider, with the correct filter on that, but there is no way to set the form to read from a data provider component. As such, I can't actually get far enough to try out the desired cascading dropdowns using the form method.
So, in short, I suspect all my problems are coming from my own lack of understanding in how BB is doing things in the background and any help that anyone can provide in getting, what I assumed would be a relatively straightforward objective, to work will be greatly appreciated!
Beta Was this translation helpful? Give feedback.
All reactions