QuickForm element group validation question
| From: | LJ Wilkinson | Date: | Wed, 04 May 2005 16:54:59 +0000 |
| Subject: | QuickForm element group validation question | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-19068@lists.php.net to get a copy of this message | ||
Hi,
I have a question about validation when grouping elements in an
HTML_Quickform. Heres the situation:
I have a quickform that has a subset of elements that are grouped using the
$form->addGroup() method. After the user submits the form, I have a
function that iterates through the values in the $_POST array and uses that
information to construct either an update or insert statement that gets sent
to the db. This function, at present, requires that the values in the
$_POST array are flat, ie no nested arrays. When you leave out the name
parameter to the addGroup function, it doesnt create nested arrays when
filling out the $_POST array: its flat, which makes me very happy.
The problem arises when I try and validate one of the elements in a group.
The normal addRule() method doesnt appear to work when you simply give it
the grouped element name as a parameter. The addGroupRule() function works
as advertised, but you need to pass it a group name, which means that I have
to give my addGroup() calls a name, which means I no longer have flat $_POST
arrays. When I leave out the group name from the addGroupRule I get a weird
error about not finding HTML_QuickForm_Header::getElementName in
QuickForm.php line 1051. I expect Im not supposed to do that.
Id really rather not make my $_POST iterator function smarter to deal with
nested arrays unless I have to. Does anyone have any suggestions as to how
I can get the look and feel of element groups (an advcheckbox and a text
element side-by-side), allow validation of one of those elements (the text
element), and get a flat $_POST array?
Thanks in advance for any help,
LJ