Jump to content

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

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.