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? My workaround (bootstrap.php: function getChecked($data = array(), $model = null, $field = null) { if (sizeof($data) && !is_null($model) && !is_null($field)) { return $data[$model][$field]; } return false; } echo $this->Form->input( 'Model.foo', array( 'label' => 'foo', 'checked' => getChecked($this->data, 'Poll', 'active') ) ); This is very similar to how I used to write non-Cake form code. But it seems kind of dumb to need to do this, considering everything else FormHelper provides. 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en