Jump to content

Disabled checkbox in cakephp


cakestar

Recommended Posts

Hello all,

 

I would like to display a disabled checkbox with its value set from the database. I have tried the following:

 

<?php echo $form->checkbox($post['Post']['flag'], array('disabled'=>'true'));?>
<?php echo $form->checkbox(‘Post.flag.$post['Post']['flag'], array(‘value’ => $post['Post']['flag']));?>

 

The first statement shows me a disabled checkbox and if I view the source I have a hidden checkbox as well but none are being passed the value of the field from the database.

 

<input type="hidden" id="" disabled="disabled"  value="0" name="data[]">
<input type="checkbox" id="" value="1" disabled="disabled" name="data[]">

 

The second statement shows this:

 

<input type="checkbox" id="‘Postflag0" value="1" ‘value’="0" name="data[‘Postflag0]">

 

Now I've changed it slightly to:

 

<?php echo $form->checkbox(Post.flag.$post['Post']['flag'], array(value => $post['Post']['flag']));?>

 

These don't work either:

 

<input type="hidden" name="data[Postflag0]" id="Postflag0_" value="0" />
<input type="checkbox" name="data[Postflag0]" value="1" id="Postflag0" />

 

I want to be able to show a disabled checkbox with a value of checked or not depending on it's value in the database.

 

Any idea how I can get this to work?

 

:D

Link to comment
https://forums.phpfreaks.com/topic/215923-disabled-checkbox-in-cakephp/
Share on other sites

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.