Answers.Body: <p>If you have access to jQuery in your project, you can <a href="https://gist.github.com/olivierbon/6c9013fa9b2841bb954909070c02e236" rel="nofollow noreferrer">do this</a>.</p>
  
  <p>Change the name of your checkboxes so craft doesn't look at them when the form gets posted and have a hidden input (named inline with your form) that you populate using using js.</p>
  
  <p>This uses jQuery but you can convert to Javascript if needed. It's not perfect but it might get you on the way :)</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T17:39:44.503Z
Answers.Text: Yes, I am using jQuery on my site. Where would I put the actual fieldname of the Craft field 'fields[logGeneral_logInputIndications]' ?  I'm assuming I put the jQuery as a hidden form field?
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T17:53:31.117Z
Answers.Text: I'm getting the following as my submitted value: `function updateP() {
    var text = '';
    $(`
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:01:09.710Z
Answers.Text: It's a front end form but only logged in members can see and submit the form.  Yes, I'm still working on this.
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:02:08.813Z
Answers.Text: I'm using that basic code, but it's not a guest entry submission form.
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:30:23.673Z
Answers.Text: For some reason, I still can't get it to work.  Here's a the code I'm using: https://codepen.io/anon/pen/exWOQq
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:41:47.523Z
Answers.Text: Still no go. I'm sorry.  I really appreciate your help but I must be doing something wrong. When I paste the jQuery code into the codepen I got this error: `index.js: Unexpected token, expected } (10:4)`
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:46:39.847Z
Answers.Text: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/89133/discussion-between-lori-and-olivier-bon).
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-20T18:33:46.750Z
Answers.Text: @oliver-bon - Sorry for the long delay, but I was able to get the latest code you sent working.  Thank you so very much!
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-20T18:35:56.010Z
Answers.Text: @Lori hey, that's cool :) Glad it worked. Mark it as a response if you can so it helps others :)
Answers.UserDisplayName: Oli
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-20T18:39:17.243Z
Answers.Text: Anyone looking for the solution, @oliver-bon provided me with code solution in our chat discussion which can be found here: https://chat.stackexchange.com/rooms/89133/discussion-between-lori-and-olivier-bon
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T17:18:34.210Z
Answers.LastActivityDate: 2019-02-01T19:10:33.623Z
Answers.LastEditDate: 2019-02-01T19:10:33.623Z
Answers.UserDisplayName: Oli
Answers.Body: <p>If you need to do this in a twig template, the <code>join</code> filter will do the job.</p>
  
  <p>Use <code>{{ yourCheckboxesValues|join(', ') }}</code> to print something like that : <code>value1, value2, value3</code>.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T16:43:09.547Z
Answers.Text: I may be misunderstanding your response @Maxime but how would I capture the joined value and submit that to my database entry? I’m wondering if I need to use a variable to collect the values and then submit the variable to the form field in the database.
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T17:22:33.693Z
Answers.Text: Do you use a plugin or a custom module to submit your form ?
Answers.UserDisplayName: Maxime Lafrenière
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T17:40:25.350Z
Answers.Text: No, I am not using any custom module to submit the form.  It's just a regular form.
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:16:16.223Z
Answers.Text: Are you submitting via ajax? Is so the answer of @Oliver Bon is a more efficient way to achieve your goal.
  
  If not; you can also create a custom module and hook a function to transform your field data before its saved on your entry (or sent by mail?)
Answers.UserDisplayName: Maxime Lafrenière
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:18:43.060Z
Answers.Text: No, I'm not currently submitting using Ajax.  I'm just submitting it normally. Sounds like the join option you submitted requires additional module which I don't have the skills to do.  But thank you so much for your input.  I was just wondering if I was missing something with the join filter.
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:24:47.587Z
Answers.Text: `join` is a builtin Twig filter
Answers.UserDisplayName: Maxime Lafrenière
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T18:27:55.900Z
Answers.Text: Yes, that's why I was wondering if I could use the `join` filter to output to a variable and then submit the variable to the Craft form field.
Answers.UserDisplayName: Lori
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-02T14:33:04.807Z
Answers.Text: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/89155/discussion-between-maxime-lafreniere-and-lori).
Answers.UserDisplayName: Maxime Lafrenière
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2019-02-01T16:36:57.360Z
Answers.LastActivityDate: 2019-02-01T16:36:57.360Z
Answers.UserDisplayName: Maxime Lafrenière
Body: <p>I have a front end form with multiple checkboxes. Is it possible to convert the checkbox values from an array to a string before it's submitted to the database?</p>
  
  <p>I want to save the checkbox values into a PlainText Craft field in the database.</p>
  
  <p>If I try to submit the front end form checkbox values into a PlainText field currently, I get the error: <code>trim() expects parameter 1 to be string, array given</code></p>
  
  <p>It looks like perhaps using the <code>join</code> or <code>merge</code> filter may accomplish this but I'm not sure. </p>
  
Tags: <form><checkboxes>
Title: Convert checkbox values from an array to a string
ThreadText: # Convert checkbox values from an array to a string
  
  (Asked by: username_0 on 2019-02-01)
  
  I have a front end form with multiple checkboxes. Is it possible to convert the checkbox values from an array to a string before it's submitted to the database?
  
  I want to save the checkbox values into a PlainText Craft field in the database.
  
  If I try to submit the front end form checkbox values into a PlainText field currently, I get the error: `trim() expects parameter 1 to be string, array given`
  
  It looks like perhaps using the `join` or `merge` filter may accomplish this but I'm not sure.
  
  **Tags:** form, checkboxes
  
  
  ---
  
  ## 2 answers
  
  ### Answer by username_1 on 2019-02-01. Score: 1 | Accepted answer
  
  If you have access to jQuery in your project, you can [do this](https://gist.github.com/olivierbon/6c9013fa9b2841bb954909070c02e236).
  
  Change the name of your checkboxes so craft doesn't look at them when the form gets posted and have a hidden input (named inline with your form) that you populate using using js.
  
  This uses jQuery but you can convert to Javascript if needed. It's not perfect but it might get you on the way :)
  
  > **Comments:**
  > **username_0**: Yes, I am using jQuery on my site. Where would I put the actual fieldname of the Craft field 'fields[logGeneral_logInputIndications]' ?  I'm assuming I put the jQuery as a hidden form field?  
  > **username_0**: I'm getting the following as my submitted value: `function updateP() {   var text = '';   $(`  
  > **username_0**: It's a front end form but only logged in members can see and submit the form.  Yes, I'm still working on this.  
  > **username_0**: I'm using that basic code, but it's not a guest entry submission form.  
  > **username_0**: For some reason, I still can't get it to work.  Here's a the code I'm using: https://codepen.io/anon/pen/exWOQq  
  > **username_0**: Still no go. I'm sorry.  I really appreciate your help but I must be doing something wrong. When I paste the jQuery code into the codepen I got this error: `index.js: Unexpected token, expected } (10:4)`  
  > **username_0**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/89133/discussion-between-username_0-and-olivier-bon).  
  > **username_0**: @oliver-bon - Sorry for the long delay, but I was able to get the latest code you sent working.  Thank you so very much!  
  > **username_1**: @username_0 hey, that's cool :) Glad it worked. Mark it as a response if you can so it helps others :)  
  > **username_0**: Anyone looking for the solution, @oliver-bon provided me with code solution in our chat discussion which can be found here: https://chat.stackexchange.com/rooms/89133/discussion-between-username_0-and-olivier-bon  
  
  ---
  
  ### Answer by username_2 on 2019-02-01. Score: 1
  
  If you need to do this in a twig template, the `join` filter will do the job.
  
  Use `{{ yourCheckboxesValues|join(', ') }}` to print something like that : `value1, value2, value3`.
  
  > **Comments:**
  > **username_0**: I may be misunderstanding your response @username_2 but how would I capture the joined value and submit that to my database entry? I’m wondering if I need to use a variable to collect the values and then submit the variable to the form field in the database.  
  > **username_2**: Do you use a plugin or a custom module to submit your form ?  
  > **username_0**: No, I am not using any custom module to submit the form.  It's just a regular form.  
  > **username_2**: Are you submitting via ajax? Is so the answer of @Oliver Bon is a more efficient way to achieve your goal.  If not; you can also create a custom module and hook a function to transform your field data before its saved on your entry (or sent by mail?)  
  > **username_0**: No, I'm not currently submitting using Ajax.  I'm just submitting it normally. Sounds like the join option you submitted requires additional module which I don't have the skills to do.  But thank you so much for your input.  I was just wondering if I was missing something with the join filter.  
  > **username_2**: `join` is a builtin Twig filter  
  > **username_0**: Yes, that's why I was wondering if I could use the `join` filter to output to a variable and then submit the variable to the Craft form field.  
  > **username_2**: Let us [continue this discussion in chat](https://chat.stackexchange.com/rooms/89155/discussion-between-username_2-lafreniere-and-username_0).  
  
  ---
  
  