RSS-Feed
Beiträge
Kommentare

If you add enum-fields to a table and want to make them editable in an admin menue you are faced to the fact that if the box is not checked - no parameter is passed to the according PHP-script. Normally you would have to write a small module of the according class containing the save function with something like this:

if(!isset($aParams['nameOfCheckboxField']))
    $aParams['nameOfCheckboxField'] = 0;

Writing a module for such simple stuff is a bit overhead. So what you can do instead in the according template is:

<input type="hidden" name="nameOfCheckboxField" value="0">
<input type="checkbox" name="nameOfCheckboxField" value="1">

So now, if the checkbox is checked, the parameter nameOfCheckboxField with value "1" is posted to the PHP script. If the checkbox is not checked then the value of the hidden field is posted - and you don't need any module at all.

Off course this might not be totally valid code. But in the backend I would not care about validation as much as about functionality.