views:

57

answers:

2

Hi...

I want to show checkbox selected in edit section if there have value in DB. i m using cakephp 1.3 version .in edit section how i will show valued checkbox true.

Please help me as soon as possible.

+2  A: 

In your controller you put

$this->set('checked', true);

And in your view:

<input type="checkbox" name="myfield" <?php echo ($checked == true) ? 'checked="checked"' : ''; ?> />

Or, if you use Form helper:

echo $this->Form->input('myfield', array('type' => 'checkbox', checked => $checked));
aRagnis
+2  A: 

You might find that (during development) refreshing the view doesn't reflect the change to the checkbox status. To overcome this, either click in the address bar and hit enter or clear the browser cache and reload.

Leo