What is the use of hidden fields for checkbox in cakePHP??
+4
A:
It's so there's always some data submitted for the field, even if the box is not checked. This becomes especially important if you're using the SecurityComponent. You can turn it off by setting 'hiddenField' => false
as an option.
deceze
2010-08-18 06:50:57
It was a real aha! moment for me when I realized why cake did this. It just makes your backend code much nicer, when you can check for == 0 rather than if the variable is set, then checking its value.
Travis Leleu
2010-08-18 15:38:51
but it gets problem when i try save with HABTM relations :(it also inserts the data with value 0
RSK
2010-08-19 04:30:46
@RSK In that case you can either `array_filter` the values in your controller, or use the `'hiddenField' => false`.
deceze
2010-08-19 04:35:01
@deceze: done `'hiddenField' => false` :)
RSK
2010-08-19 05:13:45