Form Helper - "Checked" Question

Permalink 1 user found helpful
I'm sure a savvy C5'er can answer this in a couple seconds.

Using Form Helper to build the form_setup_html in my Block.

Using the checkbox helper function.

Want the checkbox to reflect "checked" status when user reopens Block in edit mode.

I can see the checkbox helper supports this.

But the checkbox in my form does not stay "checked" in Edit mode when the field value == 1.

My table is specifying the field an "I" (integer) and the database is being updated correctly based on the checkbox status (toggles correctly between 0 and 1).

It just doesn't retrieve the DB value in Edit mode and check the checkbox when the DB value == 1.

Any help appreciated.

--djn

 
andrew replied on at Permalink Reply
andrew
Could this be a scope issue? The way the blocks work now, any column from the current block is loaded into the local scope of view.php. So, if your database column is myCBField, which can either be 1 or 0, in view.php, you should be able to access it directly

<?php print $myCBField; ?>


This would then work with the checkbox helper:

<?=$form->checkbox('myCBField', 1, $myCBField); 
?>


Unfortunately, if you use inc() to include the form_setup_html.php script, you lose the items in the local scope, unless you explicitly pass them in.

<?php
$bt->inc('form_setup_html.php', array('myCBField' => $myCBField));


Could this be what's going on?
beeman89045 replied on at Permalink Reply
I just didn't realize I needed to add the $myCBField in that 3rd parm.

Added and that did it.

Thanks ... love C5 and the Helpers!

--djn