Forums

Save a checkbox group to a field in a database

FransO 27 Apr, 2017
I have seen in a post that it is possible to use something like checkboxlist:{data: join checkboxes} in the data override of the DBsave to convert checkbox group to a comma separated string and store that in a database. However I cannot find that post any more. Can anyone show me the correct syntax or the place where this syntax is defined?
Max_admin 27 Apr, 2017
Hi FransO,

in the data override box:
table_field_name:{data/join:checkboxes_field_name}

and better you json_encode it:
table_field_name:{data/jsonen:checkboxes_field_name}


Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
FransO 27 Apr, 2017
Thanks, Max. I knew I had seen something like that but could not find it again.

I tried it, but I get "{data" as the value in the database field. Looks like it stops reading at the / and then considers it plain text.
My data overrides are:
created:{date:Y-m-d H:i:s}
maanden:{data/jsonen:maanden}

The result is:
[option] => com_chronoforms6
[chronoform] => Test form
[event] => submit
[email] => a@b.nl
[naam] => ab
[adres] =>
[postcode] =>
[woonplaats] =>
[toezegging] => 0
[termijnen] => 1
[termijnbedrag] => 0
[maanden] => {data
[betaalwijze] =>
[iban] =>
[iban_tnv] =>
[opmerkingen] =>
[submit_form] =>
[maanden_list] => 0
[created] => 2017-04-27 16:59:35

Regards,

Frans
FransO 27 Apr, 2017
Answer
Hi Max,

I solved it for now by adding a php action to the submit that implodes the checkboxes group to a hidden variable and using that hidden variable to fill the database field. The data/join construct would have been more elegant. If you find a solution to make the data/join working, please let me know.

Regards,

Frans
Max_admin 28 Apr, 2017
Hi Frans,

I have fixed this issue and it should be available in the next update, but let me know if you need an early access to the patch file.

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
FransO 28 Apr, 2017
Hi Max,

I can live with the work-around and will update the code as soon as the new update is out.

Thanks,

Frans
xoles 13 May, 2017
Hi, I'm using
table_field_name:{data/join:checkboxes_field_name}
to save a multiple selection checkbox, and works fine. But how to load that back to the checkbox in an update form? All other input fields load correctly, but the checkbox one. Thanks!
Max_admin 13 May, 2017
Hi xoles,

If you save it using jsonen instead of join:

table_field_name:{data/jsonen:checkboxes_field_name}

which is the better way, then you can add this in the "special fields" section of the "Read data":

checkboxes_field_name/json

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
Max_admin 13 May, 2017
Another way which "may" work is to add this in the "selected values" box of the "checkboxes":

{data/split:checkboxes_field_name}

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
xoles 13 May, 2017
The first option using jsonen worked great! Now it loads correctly. I have two forms, one for the first time the user fills the form and another one for updating their records.

On both forms, I use the squared brackets to indicate an array. Now, when saving an update, it crashes with this error:

Unknown column 'Array' in 'field list'

If I remove the squared brackets from the update form, it won't crash but only saves to db the last checked option.

Please advise.
Max_admin 13 May, 2017
Do you have the same line below in the "update data override":
table_field_name:{data/jsonen:checkboxes_field_name}

?

Best regards,
Max
Max, ChronoForms developer
ChronoMyAdmin: Database administration within Joomla, no phpMyAdmin needed.
ChronoMails simplifies Joomla email: newsletters, logging, and custom templates.
xoles 13 May, 2017
Yes, please find attached. Checkbox field has squared brackets.

==== EDITED =====

Sorry for the screenshot (please delete it 😶), brain is tired. Thanks for the help, it is working great!
This topic is locked and no more replies can be posted.