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?
Forums
Save a checkbox group to a field in a database
Hi FransO,
in the data override box:
and better you json_encode it:
Best regards,
Max
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
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
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
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
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
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
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
Hi Max,
I can live with the work-around and will update the code as soon as the new update is out.
Thanks,
Frans
I can live with the work-around and will update the code as soon as the new update is out.
Thanks,
Frans
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!
Hi xoles,
If you save it using jsonen instead of join:
which is the better way, then you can add this in the "special fields" section of the "Read data":
Best regards,
Max
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
Another way which "may" work is to add this in the "selected values" box of the "checkboxes":
Best regards,
Max
{data/split:checkboxes_field_name}
Best regards,
Max
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.
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.
Do you have the same line below in the "update data override":
?
Best regards,
Max
table_field_name:{data/jsonen:checkboxes_field_name}
?
Best regards,
Max
This topic is locked and no more replies can be posted.