Buy Now
Sign in

Error 1054 Unknown column 'Array' in 'field list' when UPDATING Field Multi Select

rmpaolillo , November 27 2017
Answered
rmpaolillo
Hi Max and Bob,

I have been using CF6 for a while now and I found this strange behaviour.
When I use a Field Select (Multi Select) together with a Save Data Action (INSERT) the data in the relevant DB Field are stored this way

["on foot","bike","motorbike","car"]

and so far so good.

In a CRUD scenario if I want to UPDATE/PATCH the same data loaded from database I receive this error
Error 1054 Unknown column 'Array' in 'field list


Is this a bug or I need to convert someway/somehow the data before saving.
If so this does not make much sense to me. Why in an INSERT scenario I can do it straightforward while in an UPDATE scenario I have to manipulate the data?

Regards.

Marco
Ruggiero Marco Paolillo
admin
Hi Marco,

Please post a screenshot of your "Save data" settings.

Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
rmpaolillo
Here it is...
Attachments
Administration_-_2017-11-29_18.31.38.png
Administration_-_2017-11-29_18.31.38.png
(237.39 KiB)
357 Downloads/Views
Ruggiero Marco Paolillo
admin
Hi Marco,

Please clear the "Special fields" box, this box is for fields which needs special processing, and you can not pass a shortcode inside it.

Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
rmpaolillo
Hi Max,

thank you for your reply but that did not help to solve the issue.

Please find herewith enclose the insert and update form together with the SQL dump (two lines).

Very simple scenario 2 forms two lines in the DB.

If you have time, please have a quick look.

I am stuck with it.

Marco
Ruggiero Marco Paolillo
admin
Hi Marco,

I checked your forms!

Actually the behavior of the "Insert form" is unexpected, it should not handle the array value passed by the multi select.

The way to handle this is to add this code in the "special fields" box:
select/json

This converts the multi select values to a json encoded list of variables.

You can also add the same string in the special fields box of the "Read data" in order to decode the data again when reading it, instead of using PHP code to decode the data.

Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!
rmpaolillo
Thank you Max,

you hint solved this post.

BTW, in the "data save" action in the "insert form", I did not add any code in the "special fields" box.
I did it in the "data save" action in the "update form" using
select/json

and I used the
{var:read_data4.Data4.select}
in the "select" field as you suggested removing the custom php to decode the data.
Do not know why this is not working exactly how you suggested (if I understand what you mean in your latest reply). Hope this is not related to PDO extension version on the server I am working on.
What is important is that it is now working as expected without any flaws..apparently :-).

I am enclosing the updated version of the forms to help other users.

Thanks again.

Marco
Attachments
Ruggiero Marco Paolillo
admin
Hi Marco,

Great, thank you for posting the full setup!

Happy new year!

Best regards
Max
If your main question got answered then please mark the answer using the button!​
​Please let us know if you have any problems with the new forums text editor, we appreciate your feedback!