0

I have created a custom fieldtype that uses a multiselect box. However when I save the entry in the CMS, the following error occurs

A Database Error Occurred
Error Number: 1054

Unknown column 'Array' in 'field list'

UPDATE `exp_channel_data` SET `channel_id` = '27', `field_id_108` = Array, `field_id_109`...

Any suggestions? I have checked the Multiselect fieldtype within EE and my code looks OK (I think)

1 Answer 1

1

Since you're using a multiselect element, you're posting an array of data when the entry is saved. But you can't simply insert an array into the database - you need to turn it into a string.

So in your fieldtype's save() method, you need to do something like:

return implode('|', $data);

Or:

return json_encode($data);

Then you need to turn your data back into an array in replace_tag() and display_field().

$data = explode('|', $data);

Or:

$data = json_decode($data);
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.