Replies: 1 comment
-
Did you solve it? I am trying to do the same thing |
Beta Was this translation helpful? Give feedback.
0 replies
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.
Uh oh!
There was an error while loading. Please reload this page.
-
Hello,
I’m trying to use some DynamicModelChoiceFields in a formset on a custom page.
My base form is something like
I initialise the formest in my view with
My template looks like that:
So far so good: I got two sets of selects, the selects were functional (ie, the dropdowns display my regions and sites).
However, there was no filtering: if I set a
region
, the correspondingsite
dropdown was not filtered.I added a bit of javascript to rename the
data-dynamic-params
attribute of thesite
dropdown for eachpop-xxx
div
from[{‘fieldName’:’region’,’queryParam:’region_id’}]
to[{‘fieldName’: ‘form-xxx-region’, ‘queryParam’:’region_id’}]
(wherexxx
is the index of the formset, ie theformloop.counter0
).The filtering worked correctly afterwards.
I also added a bit of code to add a new formset when I press a button, by cloning the
empty_form
:The fields of the new formset are correctly created, but the dropdowns are not functional (ie, they don’t open on a click). I’m obviously missing something here, but what? I probably should transform my cloned element as a ‘real’
APISelect
so that it gets the required event listeners, but how do I get theAPISelect
in my javascript block ?Beta Was this translation helpful? Give feedback.
All reactions