Hide Checkbox

4 posts by 2 authors in: Forums > CMS Builder
Last Post: September 2, 2009   (RSS)

Re: [InfamousNugz] Hide Checkbox

By Chris - September 1, 2009

Hi InfamousNugz,

The easiest way to get a checkbox field to display different values is by setting them in the Field Editor.

Admin > Section Editors > modify your section > modify your checkbox field

Under the field options, you'll see Checked Value and Unchecked Value, which are "0" and "1" by default, but you can change them to whatever you want.

Hope this helps! Please let us know if you have any questions or comments.
All the best,
Chris

Re: [chris] Hide Checkbox

This does not seem to work. I even tried it in the most recent version and it does not work on there either. It must change the value of the field but not what is actually displayed.

Re: [InfamousNugz] Hide Checkbox

By Chris - September 2, 2009

Hi InfamousNugz,

Sorry about that! You are right of course. I should have tested that.

That's actually a bug. I've submitted a patch and hope to have it fixed in the next release.

In the meantime, you can use the following workaround which will keep working properly if you upgrade to a version in which the bug is fixed:

Checkbox: <?php
// output checkbox field
$value = $newsRecord['checkbox'];
if ( $value == '1' ):
echo "Yes";
elseif ( $value == '0' ):
echo "No";
else: // bug has been fixed!
echo $value;
endif;
?><br/>


(Note that you'll need to change the name of the record variable and the field to match what you've got set up, as well as the strings "True" and "False" to your Checked Value and Unchecked Value; everything you'll want to change is highlighted in red above.)

Of course, after the bug is fixed, you can replace that with your original, much simpler, code.

Again, sorry about that! Please let us know if you have any more questions or comments.
All the best,
Chris