More issues with QF/QFC
| From: | Barry Steele | Date: | Fri, 09 Jan 2004 00:37:01 +0000 |
| Subject: | More issues with QF/QFC | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-10072@lists.php.net to get a copy of this message | ||
Hi,
I managed to fix the issue with defaults - essentially I had to build
the array of default values rather than use setValue, after any submit.
I now have a more problemsome issue. I have a form that build a list of
checkbox options based on fields in reference tables (some of which
require explanations). Example html is below
<html>
</tr>
<td valign='top'>Type of Incident<br>(may choose more than
one)
<font color="red"
size="1">*</font>
</td>
<td><input name="Type[1]" type="checkbox"
value="1" id="qf_a39a15" /><label for="qf_a39a15">1|Major
First Aid</label><br ><input name="Type[2]" type="checkbox"
value="1" id="qf_92b107" /><label for="qf_92b107">2|Minor
First Aid</label><br ><input name="Type[3]" type="checkbox"
value="1" id="qf_da30e9" checked="checked" /><label
for="qf_da30e9">3|Major Rescue</label><br ><input
name="Type[4]" type="checkbox" value="1" id="qf_268e1c"
checked="checked" /><label for="qf_268e1c">4|S &
R</label><br ><input name="Type[5]" type="checkbox"
value="1" id="qf_0299d6" checked="checked" /><label
for="qf_0299d6">5|Member Injury</label><br ><input
name="Type[6]" type="checkbox" value="1" id="qf_6f1868"
/><label for="qf_6f1868">6|Employee Injury</label><br ><input
name="Type[7]" type="checkbox" value="1" id="qf_274f4c"
/><label for="qf_274f4c">7|Carnival Incident</label><br ><input
name="Type[8]" type="checkbox" value="1" id="qf_862597"
/><label for="qf_862597">8|Complaint</label><br ><input
name="Type[9]" type="checkbox" value="1" id="qf_cd2fd7"
/><label for="qf_cd2fd7">9|Drowning</label><br ><input
name="Type[10]" type="checkbox" value="1" id="qf_ac7ebf"
/><label for="qf_ac7ebf">10|Near Drowning</label><br ><input
name="Type[11]" type="checkbox" value="1" id="qf_798402"
/><label for="qf_798402">11|Other</label><br ><input
size="30" name="Type[11Expl]" type="text" value=""
/></td>
</tr>
</html>
This create a nice list of options but if the user selects a set of
options (say 1,2,10,11) - $page->controller-exportValues() gives :-
["Type"]=>
array(5) {
[1]=>
string(1) "1"
[2]=>
string(1) "1"
[3]=>
string(1) "1"
[4]=>
string(1) "1"
["11Expl"]=>
string(4) "Blah"
I had expected
["Type"]=>
array(5) {
[1]=>
string(1) "1"
[2]=>
string(1) "1"
[10]=>
string(1) "1"
[11]=>
string(1) "1"
["11Expl"]=>
string(4) "Blah"
It seems to me that that it would be alot easier if I could simply set the Value to
be returned (it defaults to '1'), that way I can simply read the value.
I use :-
<code>
function createCheckBoxGroup($elementName,$dbResult)
{
while ($row = $dbResult->fetchRow())
{
//Var_Dump::display($row);
$DEGroup[] = &
HTML_QuickForm::createElement('checkbox',$row[1],null,$row[0]);
if ($row[2] == 'Y')
{
$explFieldName = $row[1].'Expl' ;
//echo "<hr>". $explFieldName;
$DEGroup[] = &
HTML_QuickForm::createElement('text',$explFieldName,'','size=30');
}
}
return $DEGroup;
}
</code>
to build the options (there are about 8 of these on the page);
Thanks in advance.
Barry
Barry Steele
hpfm solutions pty ltd
mob: 0413947980
fax: 0299817727
mailto:: barry@hpfm.biz