Hi fozzyuw,
That's because if the checkbox is not checked and no hidden has been added
to the form, once you retrieve checkbox value it will give you an error,
since when it is uncheck it just doesn't send that post value of the form.
To 'fix' this, you must create a hidden element with the same name before
the checkbox, that way, even if the checkbox is unchecked a value is passed
to the form.
Greetings,
Aldemar
----- Original Message -----
From: "fozzyuw" <[EMAIL PROTECTED]>
To: <[email protected]>
Sent: Wednesday, September 17, 2008 9:48 AM
Subject: Re: [fw-general] Zend_Form generated checkbox field
Matthew Weier O'Phinney-3 wrote:
-- Aldemar Bernal <[EMAIL PROTECTED]> wrote
(on Tuesday, 08 April 2008, 05:47 AM -0500):
just curious, doesn't Zend_Form create a hidden element with value 0 for
the
checkbox field?
No. The Checkbox element itself is "smart" enough to determine if the
value was set, and will return either the "checkedValue" or
"uncheckedValue" appropriately.
These values are 1 and 0 by default, respectively, and you can set them
using the keys as specified above, or using their accessors
(setCheckedValue() and setUncheckedValue()). If no value is provided
for the checkbox, the value of the element will be the uncheckedValue;
if the value is the same as the checkedValue, that will be used.
Ok, this post is a little old (from April) but I've got a question, what's
the whole point of this hidden element being added with a checkbox
element?
This is new to me all around and I was a little surprised and confused as
to
why this is being added.
I'm just not sure why (INI config file):
project.form.drivers.elements.businessinnov.type = "checkbox"
produces (HTML):
<input type="hidden" name="drivers[businessinnov]" value="0" />
<input type="checkbox" name="drivers[businessinnov]"
id="drivers-businessinnov" value="1" />
Thanks!
Fozzy
--
View this message in context:
http://www.nabble.com/Zend_Form-generated-checkbox-field-tp16560973p19533820.html
Sent from the Zend Framework mailing list archive at Nabble.com.