Using AJAX Update in DatabaseJoin

bggann

Active Member
I'm using a databasejoin field as a Cascading drop down. (I'd use a CCD but the relationship is a many-to-many relationship created by a multiselect dropdown and I can't see any way to do that with CDD. There is no 'list' for the many-to-many relationship, just a table).

So - I should be able to use Ajax update in the "Joins where and..." section of the DBJ.
And it almost works!

The form is used for fire management, and you need to pick a "County" and a "Fire". Counties and Fires are both lists that exist
Now
- A county can have many fires.
and
- A fire can impact many counties.
So - the relationship County <> fire is many to many. - related by a table created by fabrik "county_repeat_fire"

In the form I want to
1) Pick the county
2) Populate the "Fire" databasejoin with "Fires in that county"

To do this, I use a dbj with a "Joins Where ..." function of
SQL:
where id in (select parent_id from fire_repeat_county where county = '{funding_request___county}')

'parent_id' is the ID of the "fire" table
'county' is the ID in the county table
{funding_recuest___county} is the placeholder on my form where you pick "county"

------------
If you follow - you'll see this is basically a cascading drop down - except the relationship is indirect many-to-many through the fire_repeat_county table (and I can't do that in CDD that I can find).
-------------
What works:
On adding a new record - this works like a charm
* I pick a County
* AJAX fires and the "Fire" dropdown is populated with fires in that county.
* pick a fire.
Save the record - works like a charm.
-------------
What doesn't work - Editing a record.
--> If "apply when where is" is "Both" or "Edit"
On Edit of a record:
The "County" is populated from the table
The "Fire" is erased << ---- very bad
No AJAX is fired, (cause county did not change) so I can't pick a fire.

--> If "apply when where is "New"
On Edit of a record:
The "County" is populated from the table
The "Fire" is populated (good).
No AJAX is fired, (cause county did not change) so the "fire" dropdown is not limited to the county.
This is not horrendous - since the fire is not erased, but if the edit I'm doing was to pick a different fire in the county - it doesn't work.

Is this a bug - or am I doing something wrong.

-Bob
 
Fixed - was my dumbness
'{funding_request___county}' should be '{funding_request___county_raw}'
Hugh spotted it in a second.
Works like a charm
- bob
 
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top