1

Is it possible to submit checkbox array and text values on a front end form into a plaintext Craft field in Craft 3?

My solution worked in Craft 2 but it broke in Craft 3 due to some under the hood changes.

I don't know if this matters, but I'm using Matrix entries to build the actual form in the template. So the checkboxes and text form fields are being generated from the Matrix entries.


In Craft 2:

I'm using fieldnames with brackets like fields[logGeneral_logInputIndications][] to collect all of the values so they are appended and not overwritten (like it would be if I made it a single line text field.)

Here's an example of what is submitted to the Craft plaintext field:

["Cardiac Activity","Normal","Effusion","Small","No LV Function Assessment Performed","No RV Diameter Assessment Performed","No IVC Diameter Assessment Performed"]

All of the items you see above like "Cardiac Activity", "Normal", etc. are all checkboxes or text form fields on the front end.

I'm using fieldnames with brackets like fields[logGeneral_logInputIndications][] to collect all of the values so they are appended and not overwritten (like it would be if I made it a single line text field.)


In Craft 3:

When I submit the form in Craft 3, I get trim() expects parameter 1 to be string, array given error because the form field I'm submitting like fields[logGeneral_logInputIndications][] is an array but the Craft field the values are writing to is plaintext.


Is it possible to merge the values without building a module?

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.