1. Fabrik 3.9 has been released. If you have updated Joomla to 3.9, this is a required update.
    Dismiss Notice

Add records in a cascading dropdown

Discussion in 'Community' started by FcPeras2, Jun 14, 2018.

  1. FcPeras2

    FcPeras2 New Member

    Level: Community
    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.
     
  2. Sophist

    Sophist Well-Known Member

    Level: Community
    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.
     
  3. FcPeras2

    FcPeras2 New Member

    Level: Community

    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: Jun 15, 2018
  4. Sophist

    Sophist Well-Known Member

    Level: Community
    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 (Text):
    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.
     
  5. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Also, always stick quotes round placeholders being used as values, so if the placeholder is empty, you still get valid SQL, like ...

    Code (Text):

    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
     
  6. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    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
     
  7. FcPeras2

    FcPeras2 New Member

    Level: Community
    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.

    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.
     
    Last edited: Jun 18, 2018

Share This Page