Reputation: 15220
I have a Table column named active
which may have a value 1 or 0
in my add.ctp
I am creating a checkbox using
<?php echo $this->Form->checkbox('active'); ?>
and similarly in my edit.ctp
template
but regardless of if the checkbox is checked or unchecked the value saved in Database is always 1 and i also don't know in the active=1
how to set it to checked
Upvotes: 0
Views: 590
Reputation: 24354
Assuming the database column is a BOOLEAN type. You should create the checkbox like this instead:
<?php echo $this->Form->input('active'); ?>
It should automatically output it as a checkbox..
If it doesn't, try clearing the model cache in tmp/cache/models
and trying again
Upvotes: 1