Forums

how to store multiple values in db table

giulia72 23 Mar, 2017
Hi
I have a form with a check box fields (the user can make multiple choise).
I have created an associated table to this form and activated a db save action.

It works except for check box values as only the first one selected is stored.

I think the problem is the field structure in db table: as default is set to VARCHAR

Could you help me?

Thank you
GreyHead 23 Mar, 2017
Hi giulia72,

Your checkbox group can return multiple values so it needs to have an array name ending in [] e.g. checkbox_1[]

To save the selected values in a database table you need to convert the array into a comma separated string. You can do this with a Handle Arrays action in the form On Submit event before the DB Save action.

Bob
giulia72 23 Mar, 2017
Hi Bob
I have added Handle array action but nothing happens , same result.

Do I have to do any other configuration?
GreyHead 23 Mar, 2017
Hi guilia72,

Please drag a Debugger action into the On Submit event, then submit the form and copy and paste the debug results here.

Bob
giulia72 24 Mar, 2017
Hi Bob
it works
I missed to insert [ ] in the field namme of array

Do you know if it s possible the array values can be stored in different columns in the db table?
GreyHead 24 Mar, 2017
Hi giulia72,

You could use a Custom Code action to break the array up into separate entries in the $form->data array - or you could use a second table linked to the first to store them.

Bob
giulia72 24 Mar, 2017
ok for the moment I will leave it as it it
xoles 13 May, 2017
Hello! What or where would the "handle array action" be on CFv6 ?
Max_admin 13 May, 2017
Hi xoles,

I have replied here already:
http://www.chronoengine.com/forums/posts/t103431.html#368117

Best regards,
Max
Max
ChronoForms developer...
Did you try ChronoMyAdmin for managing your Joomla database tables ?
This topic is locked and no more replies can be posted.