Coding Recommendation using HTML_Quickform
| From: | James 'Chip' Kaufman | Date: | Mon, 03 Nov 2003 17:38:17 +0000 |
| Subject: | Coding Recommendation using HTML_Quickform | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8736@lists.php.net to get a copy of this message | ||
I have this code w/o quickform:
for ($i=0; $i<$workcount; $i++) {
$sid='sd' . $i; // unique id for start date
$eid='ed' . $i; // unique id for end date
echo <<<INPUT_FORM2
<TABLE>
<TR>
<TH class=l>Req. Start</TH>
<TH class=l>Req. End</TH>
</TR>
<TR>
<TD><input type='text' size='10' name='reqdate[]'
id='$sid'
value='{$reqdate[$i]}'>
<TD><input type='text' size='10' name='reqdate[]'
id='$sid'
value='{$enddate[$i]}'>
etc.
I need to validate the dates that are entered using a Javascript
function, but I don't know up front how many elements will be in the
date arrays. What I ended up doing was defining the variable name with
the square brackets and assign each a unique id. This all works fine.
What is the recommended approach using QuickForm? Something like this:
$form->addElement ('text', "reqdate[]", 'Req. Start',
array('size'=>'10'));
$form->addElement ('text', "enddate[]", 'Req. End',
array('size'=>'10'));
I don't think that QuickForm likes the square bracket syntax. How about
setting the value? Does it go into the default value array or should I
set it in the addElement line?
--
James 'Chip' Kaufman
jkaufman@wamnetgov.com
952-346-3532
PGP key: 697D43DE