Hello, i want field's values of the form to be dependant, so to speak, on previous fields selections. For example, form has first choice Food or Drink; the second choice would depend on whether user selected Food (it would offer Pizza or Burger) or Drink (offers are Coffee or Tea).
Is it possible to do so? Should i not be using forms at all in this use case?
#How to dynamically generate field values in the django form?
5 messages · Page 1 of 1 (latest)
That would have to be done on the front end with JavaScript, and isn't something that pure Django can do
That works, any tutorials for this?
None that I can think of for this specifically off-hand, but you'll need some way for JavaScript to know the mappings of "this choice in X field means these choices available in Y field", listen for changes in field X and update the options in field Y
You can also add custom field validation to the Form so the backend can bail if somebody bypasses the JavaScript and submits invalid combinations