On Oct 17, 4:41 pm, cricket <[email protected]> wrote:
> 1.3.4
>
> How are others dealing with the broken checkbox implementation?
> Situation: I want a checkbox to have a default state, checked or
> unchecked. To have the former:
>
> echo $this->Form->input(
>         'Model.foo',
>         array(
>                 'label' => 'foo',
>                 'checked' => 1
>         )
> );
>
> However, if the value in the DB is 0 the checkbox will be displayed
> checked. It seems to me that the default should only be used if the
> value in $data is empty or the key doesn't exist. Bug reports
> explaining this have been ignored. How are others handling this
> situation?

I disagree that, that is how it should work.  If you put checked, you
should get checked.  Being specific gets specific behavior, leaving
things undefined gets you magic.  If you want default values, the
populate $this->data in your controller, when the action has no POST
data.  This will get you the behaviour you want.

-Mark

Check out the new CakePHP Questions site http://cakeqs.org and help others with 
their CakePHP related questions.

You received this message because you are subscribed to the Google Groups 
"CakePHP" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to