cakePhp $html->checkbox htmlattributes issues
It’s not obvious but certainly I was caught offguard for a certainly small issue that made me use the old habit of doing the checkbox thingy.
When I explicitly tell the html helper to check a certain checkbox, I always do array('checked'=>'checked'); to add the checked attribute but I am left wondrin why it does not do what I want. I really can’t remember what I did to make others work but certainly it was such a headache that I opted to use the old <input type=’checkbox’ /> tags. After looking at the html helper, I found out the ffg comments
* + ‘compact’
* + ‘checked’
* + ‘declare’
* + ‘readonly’
* + ‘disabled’
* + ’selected’
* + ‘defer’
* + ‘ismap’
* + ‘nohref’
* + ‘noshade’
* + ‘nowrap’
* + ‘multiple’
* + ‘noresize’
*
* And its value is one of:
* + 1
* + true
* + ‘true’
*
* Then the value will be reset to be identical with key’s name.
* If the value is not one of these 3, the parameter is not output.
This does not only involve the checkbox but all the input tags because they pass this step first before outputting any parameter. I wish I explored on this much earlier, it would have saved me a lot of energy. Oh well, atleast I learned something new for the day
You may also want to check the function yourself. It is the function _parseAttributes($options, $exclude = null, $insertBefore = ' ', $insertAfter = null) in the html helper. You can see the $insertBefore = ' ', $insertAfter = null, this is useful for checkboxes to add labels but currently, that option is not available in the 1.1 version. Someone already asked this enhancement in trac so I am not reporting it again. I hope that saves some of your time





Recent Comments