1. Fabrik 3.8 has been released. As usual, we strongly recommend that you backup your site (using Akeeba) before upgrading. Report any issues in the forums, we will answer promptly.

Datajoin elements save null when runder as checkbox

Discussion in 'Standard Support' started by confis, Oct 12, 2017.

  1. confis

    confis Member

    Level: Standard
    Hi,
    Datajoin elements save null when runder as checkbox for multiple select

    Any way to save multiple select on datajoin?

    Like in checkbox element
     
  2. cheesegrits

    cheesegrits Support Gopher Staff Member

    Level: Community
    Are you talking about what actually gets saved in the main table?

    Checkbox and multiselect joins automatically create a many-to-many mapping tables, named <parent-table>_repeat_<joined-table> ... so for instance I have a checkbox join to us_states on my fab_cdd_test table, so it creates a fab_cdd_test_repeat_us_states table, which has a standard many-to-many map - a parent_id FK pointing back to the parent row, and a us_states FK pointing to the joined us_states row. And for each checkbox selection, a row is created in that map.

    But yes, the main table's field (in my case 'us_states') will be null.

    That's just a database thing. For a dropdown join, with only a single selection, we can do a simple one-to-one FK join, where the field on the parent table has the FK value pointing to the joined table. But for multiple selections, a many-to-many map table is required. WIthout a map table, you can't have multiple values for a join.

    Checkbox elements don't have to join to other tables, so for those we just store the multiple selections as a JSON array.

    -- hugh
     
  3. confis

    confis Member

    Level: Standard
    Got it, thank you

    Sent from my ONEPLUS A3010 using Tapatalk
     

Share This Page