dependent select box in editor
dependent select box in editor
edanyildiz
Posts: 43Questions: 13Answers: 4
Dear All,
I have 2 select boxes in the editor. Is there a way to populate the second select box using the first one while the user is creating a new record.
I had a chance to read the dependent() example but there is no clear example or post about this.
This discussion has been closed.
Answers
For example;
First select - Countries
second select - Cities
Basically you need to use:
The URL given would need to return JSON in the form:
based on the parameters submited of course.
So essentially you need to write the server-side script to get the list of cities (which would presumably involve a database lookup).
Regards,
Allan
Thank you Allan.
I hope we have an example including serverside script when you have free time.
Hello,
I have a very similar query. I am developing a webapp in Django. I am trying to populate list of US counties based on the State selected. I have two select fields. First one is the state and second is the list of counties. What should I specify as the 'options' for county field? Below is the relevant code snippet:
And get_county_list_json() reads thus:
Appreciate if experts here can kindly advise me,
Thanks,
Harsha
Initially an empty array would be fine. The key is the response to the Ajax response that the
dependent()
method makes. Is that aspect working?Allan
Allan, thanks. I have got this working. A question though - Does the dependency prevent a user from selecting a different option than what was set by the dependency rule? In other words, can a user still edit the dependant field?
Yes they could do if the option is there for them to do so.
dependent()
can also be used to change the options of the field - so you could just set it to be a single option if you want to force a value.Allan
Thanks Allan, Working now.