I've just tried trunk, and have the same behaviour.
Having looked again at the HTML being generated, it seems quite odd:
<dd> <input name="courseList[CEAudio]" value="0" type="hidden">
<input
options="enroll notenroll" id="courseList[CEAudio]"
name="courseList[CEAudio]" value="notenroll" type="checkbox"> </dd>
You can't be using trunk. IDs on dijit CheckBoxes were fixed three
days
ago. Please update your svn checkout and re-verify.
You were right; I wasn't using the latest trunk and have now fixed
this. The HTML is much better:
<input name="courseList[CBAudio]" value="0" type="hidden"><input
id="courseList-CBAudio" name="courseList[CBAudio]" value="notenroll"
type="checkbox">
but the code still seems to be doing slightly the wrong thing; instead
of putting the unchecked value into the hidden element, it puts it
into the checkbox element, and the hidden element continues to show a
value of 0.
For the elements that are checked by the $form->populate() method, the
checkbox's value is "enroll" (the correct checked value).
I quickly verified this if I don't set the checked/unchecked values
when I create the form elements - both the checkbox and hidden element
show a value of '0', so I'm guessing at this point it is a bug?
Most Dojo widgits have their id's generated as (for example)
courseList-CEAudio ([] replaced by -), and I'm still confused as to
how
the hidden/checkbox of the same name are supposed to function
(although
they seem to, so I can't complain).
Basically, when a checkbox is unchecked, either no value is
submitted or
an empty string is submitted for it (depending on the browser). This
causes issues on the server-side, particularly if the value is
required.
The hidden element ensures a value is returned when the checkbox is
unchecked.
Within Zend_Form/Zend_Dojo, we allow you to set both the checked and
unchecked values; the unchecked value is placed in the hidden element,
the checked value in the checkbox itself. This way you get the
appropriate value back based on the status of the checkbox at
submission.
This makes great sense :-)
Thanks,
Andrew
--
Andrew Yager, Managing Director (MACS BCompSc MCP)
Real World Technology Solutions Pty Ltd
ph: 1300 798 718 or (02) 9037 0500
fax: (02) 9037 0591 mob: 0405 152 568
http://www.rwts.com.au/ or http://www.stonebridgecomputing.com.au/