Hello everyone,
I'm developing a rather complex form where the selection options need to depend on what the user selects in a previous field.
As a simplistic example, let's say there are two models, Owner and Thing, where an Owner can have multiple Things. I would like to have a form where you first pick an Owner, and then pick a Thing that the Owner has (and only Things the owner has). Ideally this would be done without using multiple forms (as I have many such complicated fields). There can be many owners so it is not feasible to have a hidden dropdown for each owner.
Here is sort-of what I envision:
db.define_table("person", Field('name'))
db.define_table("thing", Field('owner', 'reference person'))
db.define_table("thing_selection", Field('owner', 'reference person'),
)
where thisform is what the user is submitting as a SQLFORM (or crud.create)
I imagine the solution will likely require AJAX. Is there a good resource or practice or things to keep in mind for editing a dropdown form with ajax, and how might I do it? Or if you have any other suggestions they are welcome. Thanks!