How to convert email template for checkbox fields from 0/1 to no/yes - AS THE DEFAULT FOR CHECKBOXES IN A FORM FOR SUBMISSIONs/Emails

9 posts by 3 authors in: Forums > CMS Builder
Last Post: January 9, 2019   (RSS)

By Codee - January 1, 2019 - edited: January 2, 2019

Hello,

Person submits a form to the website and the form has several checkboxes for choices (just yes/no or check if yes).  Utilizing the email template function of CMSB...how do I handle the checkboxes when sending a confirmation email to the end users?  This is to avoid the end user (who submitted the form) from getting an email with several "1's" or "0's" in it. Thank you in advance.

How to convert email template for checkbox fields from 0/1 to no/yes

By Codee - January 2, 2019

Hi Jerry,

Thank you for responding and for sending your code snippets...I really appreciate that.

I DID review your forum posts you mentioned prior to sending my request to the forum. I am hoping for a slightly more elegant solution that would essentially convert the 1/0 to yes/no for ANY and ALL checkboxes as a default setting.  I recognize that the email templates don't support PHP code but this is, technically, an important issue.  CMSB is essentially the core that helps fuse the database with the PHP code as well as process the email templates and other functions as a standard for sites utilizing CMSB. It is not just a matter of being "easier" on the coders/programmers using CMSB for their clients sites - but also as a consistent solution.

So I started this thread in the forum to see if the possibility is there before I start adding a lot of code strings...1 for each checkbox on any forms and I'm working with a lot of forms now.

Thanks!

How to convert email template for checkbox fields from 0/1 to no/yes

By gkornbluth - January 2, 2019

Hi Equinox,

Just curious.

Do you create a different email template for each form?

Would there ever be a case where a checkbox is used for other than yes or no?

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

How to convert email template for checkbox fields from 0/1 to no/yes

By daniel - January 4, 2019

Hi Equinox,

This is a bit of a tricky problem, and unfortunately, in most cases, there is not going to be a way to change the values of submitted checkboxes in a way that doesn't require updating each individual form. There are some potential solutions that could work if some specific setup is done prior to creating the forms, but it's unlikely to work on existing forms.

It sounds like you might be using the Form Generator plugin to create the forms (or similar HTML), in which case the checkbox HTML should look something like this:

<div class="form-group">
  <label>Checkbox</label>
  <div>
    <input type='hidden' name='checkbox' value='0'>
    <input type='checkbox' name='checkbox' value='1' id='checkbox' <?php checkedIf('1', @$_REQUEST['checkbox']) ?>>
    <label for='checkbox' style='font-weight: normal'>checkbox</label>
  </div>
</div>

Probably the simplest thing you can do is change the value attribute here from 0/1 to no/yes, which will also update the submitted value.

I hope that's helpful - let me know if you have any more questions!

Thanks,

Daniel
Technical Lead
interactivetools.com

How to convert email template for checkbox fields from 0/1 to no/yes

By Codee - January 8, 2019

Hi Daniel,

Thank you! Very simple, elegant and easy to instigate.

Cheers!

How to convert email template for checkbox fields from 0/1 to no/yes

By Codee - January 8, 2019

Hi Jerry,

Of course each site is unique but there is almost always something that can work more simply, more readily, more securely and more fun. ;-)  Most, or many, of the checkboxes I use will simply be a "yes/no" but there are plenty of examples where they might not be.  I guess the short of it, for me, is "it depends" and the dependent part is usually "depends upon what the client needs."

How to convert email template for checkbox fields from 0/1 to no/yes

By gkornbluth - January 8, 2019

Sounds right.

But it does unfortunately eliminate the possibility of a 'one size fits all' solution.

BTW, have you tried Daniel's idea?

Curious to see what you find when updating a check box with a text value, (or is that not how it works).

Anyway, if you find solutions, could you pass them on?

Thanks,

Jerry Kornbluth

The first CMS Builder reference book is now available on-line!







Take advantage of a free 3 month trial subscription, only for CMSB users, at: http://www.thecmsbcookbook.com/trial.php

How to convert email template for checkbox fields from 0/1 to no/yes

By Codee - January 9, 2019

Hi Jerry,

Actually I DID try it but it looks like the backend has to be changed from a checkbox to receiving input as well. (duh? right?)  On the current site I already came up with a different solution in the interim...I have a "fix it or eliminate it" mentality. Might seem simple-minded but eliminates a lot of headaches. ;-)