Forums

Dynamic Dropdown in v7 with Multiselect

luken 23 Oct, 2020
Hey there,

I'm trying to make a multiselect on a dynamic dropdown work.
Loading the data from db works.

Problems:
- When clicking several options (multiselect), the names don't appear --> just white boxes.
- Also the DB Save doesnt work. When selecting multiple options (or trying to do this), there's nothing saved in the db on submit. I guess it has something to do with array to string conversion and I've read something about an "Array Handler" in former CF versions, but how does that work in CF 7? Which datatype does the db column must have?

Could you help me?
Max_admin 23 Oct, 2020
so I have just tested the demo Dynamic dropdown form, set the dropdown to multi selection and I could select multiple options without an issue.

for the data save, enable the debugger and verify that the options list is in the data array, if they are then it's a data save issue, do you save to the DB Log or a using Save Data ?
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
luken 26 Oct, 2020
Hey, thanks for answering.

I switched to checkboxes. Loading options from db works. There's just the problem in saving. I am using the DB Save.

When I make a selection of 2 checkboxes (for example), how can I save that to a single table field in db with JSON encoding?

The related table field is configured as JSON (data type).
Max_admin 27 Oct, 2020
in the Save Data > Advanced Settings > Data Source >

add your field name and set the value type to JSON encode!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
luken 27 Oct, 2020
Hey Max,
thank you for answering!

That unfortunately doesnt't work. When I select a checkbox and click (save), then just [] is in the table field (when I look in the table with MySQL Workbench for example).

You see my configuration in the pic. Here, "article" is my table field (with data type JSON, configured in the Workbench) and "boxes_data" is the Field Name of the checkboxes. What's wrong here?

I have to say that the content / the data source of the checkboxes is dynamic options. The options are read in with {var:model.tablefield} as Option Value and Option Text. Showing this, works.
Max_admin 27 Oct, 2020
Hi luken,

this is a bug, I have just fixed it here, if you need a patch file then please send me a message using the contact page!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
Max_admin 27 Oct, 2020
Reading data back is possible, you mean decode the JSON data, yes ? in the Read Data > Advanced Settings > Special fields, add the field name and select JSON Decode, that will decode it, then if you enable the Populate Fields in the Behaviors in the Read Data, it will populate form fields with data, but the fields names should match the Model.table_field_name, so if the Model is "Test" and the table field is "x", then your form field name should be Test.x
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
luken 28 Oct, 2020
Hey Max,

thank you very very much!! Saving works fantastic!

Just one more question:
When reading back the data from json, what about the settings in the radio buttons (view). So, I set Populate Fields in the Read DB, then I named the field of the radio buttons exactly like that (model.table_field_name). What about the dynamic options (the data source, the option value and option text)?
Actually, I just want the json data to be radio buttons. ?
Max_admin 28 Oct, 2020
The dynamic options are for the whole list of options, they need their own "Read Data".

if you want to populate the form fields (the radio and others) then you need to a special Read data for that as I explained in the previous post!
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
You need to login to be able to post a reply.