Friday, August 27, 2010

Checkbox field always is 1, regardless whether checked or not

Hi all

I have a checkbox "activated" in my "TermolinoWord" model. I'd like to
make some custom validation in the controller where I check if the
checkbox is checked or not.

I wanted to simply check the value of the model object using $model-
>field("activated"), but for an unknown reason it always returns 1,
regardless whether it's checked or not! When using $this-
>data['TermolinoWord']['activated'], it works as expected:

$model =& $this->{$this->modelClass};
echo $model->field('activated'); // always 1
echo $this->data['TermolinoWord']['activated']; // 1 when checked, 0
when unchecked

What's the problem here?

Thanks a lot for help,
Josh

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 cake-php@googlegroups.com
To unsubscribe from this group, send email to
cake-php+unsubscribe@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en

No comments: