Problems with Checkboxes in Membership Edit Profile Form

8 posts by 4 authors in: Forums > CMS Builder
Last Post: April 1, 2015   (RSS)

By Mikey - March 19, 2015

Hey Matrix,

I think what you're missing is a method to determine the value of the field as checked or (1 for true). Below is a snippet of code I used on a form similar to what you're trying to achieve. I also changed the code to match yours.

<input type = "checkbox" name = "show_contact" value = "1" <?php checkedIf("1", @$_REQUEST['show_contact']);?> />

If the above doesn't work, then try this line of code instead. The only difference is "1" is set to "Yes", which I bolded in both lines of code.

<input type = "checkbox" name = "show_contact" value = "Yes" <?php checkedIf("1", @$_REQUEST['show_contact']);?> />

And the other portion - which you already have.

$colsToValues['show_contact']      = @$_REQUEST['show_contact'];

Hope this helps - Zicky

Thanks got this to work! Now I am having conflicts with twitter-bootstrap with the way they handle checkboxes....

http://getbootstrap.com/css/#forms

Instead of just a checked status they rewrite the html to having a span around the input.

Checked looks like this

<span class="checked">

<input checkbox>

</span>

Unchecked is the same without the span. I am also having trouble passing the values from the checkbox with the way bootstrap handles checkboxes. Anyone had to work around this before?

By Damon - March 20, 2015

I checked out the Bootstrap link, checked the checkbox and viewed the page source to see this:

<div class="checkbox">
  <label>
    <input type="checkbox"> Check me out
  </label>
</div>

What version of Bootstrap are you using?

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By Damon - March 20, 2015

I checked out the Bootstrap link, checked the checkbox and viewed the page source to see this:

<div class="checkbox">
  <label>
    <input type="checkbox"> Check me out
  </label>
</div>

What version of Bootstrap are you using?

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

im using bootstrap 3.

By Damon - March 31, 2015

Sorry for the delay in getting back to you. I was hoping someone with more experience with Bootstrap would add some ideas.

Can you start by getting the form to display results (checked box) outside without using Bootstrap?

Could you send in a support request so I can see what is currently happening and review the code?
https://www.interactivetools.com/support/email_support_form.php?priority=free

Cheers,
Damon Edis - interactivetools.com

Hire me! Save time by getting our experts to help with your project.
http://www.interactivetools.com/consulting/

By gregThomas - April 1, 2015

Hi,

I often use bootstrap in my projects, and have found that you can use the standard checked="checked" attribute in checkbox tags to load the checkbox as checked. Here is an example from a recent project:

                <div class="checkbox">
                  <label>
                    <input type="hidden" name="covered_by_insurance" value="0" />
                    <input name="covered_by_insurance" value="1" <?php checkedIf(@$_REQUEST['covered_by_insurance'], '1'); ?> type="checkbox"> Is this item covered by insurance? (Should it be included in insurance calculations)?
                  </label>
                </div>

The checkedIf function is built into CMS builder, and will echo checked="checked" if the two variables passed into it are the same.

Cheers,

Greg

Greg Thomas







PHP Programmer - interactivetools.com