QuickForm - several questions
| From: | Frank Bax | Date: | Tue, 01 Jul 2008 22:14:07 +0000 |
| Subject: | QuickForm - several questions | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-29059@lists.php.net to get a copy of this message | ||
I've got my first form done in 1.5 days (uses groups, text, textarea,
radio, advcheckbox, files) with results being emailed using Mail &
Mail_Mime. It works; but there are some things I'd still like to change
a little bit.
0) Thanks to helpers on #pear irc channel for directing me to
advcheckbox instead of checkbox!
1) Labels for text elements ('First', 'Middle', 'Last') in a group do
not appear on the form (this works for grouped radio, checkbox).
$name[] = &HTML_QuickForm::createElement('text', 'First', 'First',
array('size'=>20,'maxlength'=>30));
$name[] = &HTML_QuickForm::createElement('text', 'Middle', 'Middle',
array('size'=>10,'maxlength'=>30));
$name[] = &HTML_QuickForm::createElement('text', 'Last', 'Last',
array('size'=>20,'maxlength'=>30));
$form->addGroup($name, 'Names', 'Name of Applicant: ', '<br>');
2) With above first,middle,last name; how do I create a rule to make
first/last required; but middle optional? Using addRule on elements
seems to be ignored; using addGroupRule seems to make all three elements
required.
$form->addGroupRule('Names', 'Applicant\'s name is required',
'required');
$form->addRule('First', 'Applicant\'s first name is required',
'required');
$form->addRule('Last', 'Applicant\'s last name is required',
'required');
3) If I combine yes/no radio elements and a text field into a group. Is
it possible to require the text field be entered whenever the 'Yes'
radio was selected?
$coll[] = &HTML_QuickForm::createElement('radio', null, null, 'Yes',
'College_Yes');
$coll[] = &HTML_QuickForm::createElement('radio', null, null, 'No',
'College_No');
$coll[] = &HTML_QuickForm::createElement('text', 'Diploma:', null,
array('size'=>25), 'Program:');
$form->addGroup($coll, 'College', 'College Diploma: ', '<br>');
4) If user enters files to be uploaded; but server finds validation
errors; the filename disappears and must be reloaded. Is there a way to
avoid this behaviour.
5) If I specify client-side required rule for radio and/or checkbox; it
is only checked on server side.
$form->addGroupRule('FullG', 'A yes/no answer is required',
'required', '', 'client');
6) After calling $form->freeze(); 'file', 'submit' and 'reset' elements
are not frozen?
Frank