You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
And I tried many other things like : tags[0].options[2].selected = true or tags[0].options.selectedIndex = 2 ...
If I change the tags form field to forms.ModelMultipleChoiceField, the above function works fine.
The option is correctly selected and the field is no more editable.
But this is not the display that I want.
Finally, for DynamicModelMultipleChoiceField the unique solution I found is to empty the field's options and generate new ones:
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
Uh oh!
There was an error while loading. Please reload this page.
-
Using the form
DynamicModelMultipleChoiceField
is really interesting when filtering options from another field.This works pretty well!
But when I want to change the form from Javascript, some changes are not visible on the page.
Example from the
tags
field inInterface
edition page :Javascript :
And the
SelectionChange
function that I tried with many possibilities :I want to select dynamically an option and set the field on readOnly.
And I tried many other things like :
tags[0].options[2].selected = true
ortags[0].options.selectedIndex = 2
...If I change the

tags
form field toforms.ModelMultipleChoiceField
, the above function works fine.The option is correctly selected and the field is no more editable.
But this is not the display that I want.
Finally, for
DynamicModelMultipleChoiceField
the unique solution I found is to empty the field's options and generate new ones:But I did not find any solution for setting
readOnly
option on the field.Does anyone have an idea to solve this? This solution is not really clean.
Thanks in advance.
Beta Was this translation helpful? Give feedback.
All reactions