Add records in a cascading dropdown

FcPeras2

New Member
Hi!
I'm trying to have a form in wich a cascading dropdown has a button to add records in the corresponding list (similar to the "Add option in front end" button).

I know the "Add option in front end" option isn't available for cascading dropdowns so I have tried using a button element with the "icon-plus" image to simulate the same effect. Problem is, the button uses javascript, hence, I can't actually insert records in the list.

Is there any way I can solve this problem?
Thanks in advance.
 
You should be able to mimic the cascading dropdown element using a databasejoin element and a where clause and then you can enable the Add option in front end function.

However, I would expect that when you use the Add option in front end, the earlier cascading dropdown(s) value(s) will probably not be pre-populated in the new record pop-up form.

It would be great to have additional functionality which either:

a. Does the Add in front end for Cascading Dropdowns with prepopulation of high level cascading dropdown values; or

b. Additional functionality to allow pre-population to be specified for databasejoin Add in front end.
 
You should be able to mimic the cascading dropdown element using a databasejoin element and a where clause and then you can enable the Add option in front end function.


Thanks for the reply Sophist.

I have tried to do that, but the placeholder I'm using in "data - where " doesn't return any value for some reason.
The placeholder is "fzmms_quotereq___contact_id". If, for instance, I write "WHERE {fzmms_quotereq___contact_id} = 1" in the "data - where" area, when I load the form I get an SQL syntax error near "= 1 ORDER BY text ASC" (the "order by" is created by Fabrik). It seems to me that the placeholder doesn't "exist" when the form is loaded, but can't tell...
 
Last edited:
Turn fabrik debug on and add ?fabrikdebug=1 to the form url. This will give you debugging output which will include the SQL that is being run in one of the accordions.

However using "WHERE {fzmms_quotereq___contact_id} = 1" will either produce all the records or none of them depending on whether the contact_id is 1 or something else because it will translate either to "WHERE 1 = 1" or "WHERE 2 = 1" - which is probably not what you want. You are most likely to want a where clause which looks something like:
Code:
WHERE {thistable}.`contact_id` = {fzmms_quotereq___contact_id}

Please post a screen shot of the configuration page for the dropdown and the SQL that is being produced.
 
Also, always stick quotes round placeholders being used as values, so if the placeholder is empty, you still get valid SQL, like ...

Code:
WHERE {thistable}.`contact_id` = '{fzmms_quotereq___contact_id}'

So if the placeholder is empty, you get ...

`fzmms_quotereq`.`contact_id` = ''

... instead of ...

`fzmms_quotereq`.`contact_id` =

... which would error out.

-- hugh
 
Or you can provide a default for the placeholder, using || ...

{yourtable___whatever||0}

... which will be used if the placeholder yields and empty string.

-- hugh
 
Turn fabrik debug on and add ?fabrikdebug=1 to the form url. This will give you debugging output which will include the SQL that is being run in one of the accordions.

I did that, but there's no SQL there...? It just shows some arrays with fields related with the table and other things but no SQL.

However using "WHERE {fzmms_quotereq___contact_id} = 1" will either produce all the records or none of them depending on whether the contact_id is 1 or something else because it will translate either to "WHERE 1 = 1" or "WHERE 2 = 1" - which is probably not what you want.

Yes I'm aware of that, but thanks. I had created a record with "contact_id" = 1, just to test if the SQL was actually beeing executed.

EDIT:
I just tried that SQL and it worked just fine. Thanks!

Also, thanks Hugh, for that tip.
Also, always stick quotes round placeholders being used as values, so if the placeholder is empty, you still get valid SQL
 
Last edited:
We are in need of some funding.
More details.

Thank you.

Members online

Back
Top