QF: checkbox element
| From: | Mike Carter | Date: | Mon, 20 Oct 2003 10:32:23 +0000 |
| Subject: | QF: checkbox element | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8492@lists.php.net to get a copy of this message | ||
Hi,
I'm trying to work out how to change the value attribute which is returned
when a checkbox is "checked".
I look through an array of checkbox values and names,
$problems = array('123' => 'angina', '456' =>
'heartattack', '789' =>
'ischaemic', '321' => 'stroke'); etc...
foreach($problems as $key => $value){
$this->addElement('checkbox', $key, $value, null);
}
$value is the label and $key is the number I would like to return if the
checkbox is ticked.
The generated HTML is:
<input name="123" type="checkbox" value="1"
id="qf_be76e4" /><label
for="qf_be76e4"></label>
However the values being stored in the quickform controller container are:
[0]=> string(1) "1" [1]=> string(1) "1" [2]=> string(1)
"1"
The above array key is going up numerically, so how does it know which
checkbox should be checked? Should the array key not be linked to the input
s "name" attribute? Ie ["123"] => string(1) "1" ?
Also note that I set the checkboxes label to null, yet in the HTML I still
get the <label></label> tags; is there a way to prevent this additional mess
in the HTML code?
I checked through the QF checkbox.php code, and also had a peek at the
advanced checkbox, but couldn't see an immediate solution to either of my
problems.
Any ideas?
Regards,
--
Mike Carter
________________________________________________________________________
This email has been scanned for all viruses by the MessageLabs Email
Security System. For more information on a proactive email security
service working around the clock, around the globe, visit
http://www.messagelabs.com
________________________________________________________________________