For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > May 2005 > Re: [PEAR] QuickForm element group validation question









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] QuickForm element group validation question
Matte Edens

2005-05-04, 8:57 pm

In your "addGroup()" call, I think you might want to set a name for your
group but set the $appendName parameter to false. I think that'll do
what you want it to do. Keep it flat but still referencable inside the
addGroupRule() function.

see the description of the parameters for the addGroup() rule at the
following url.

<http://pear.php.net/manual/en/packa...rm.addgroup.php>

matte - matte@arubanetworks.com
webmonkey » arubanetworks.com <http://www.arubanetworks.com>
Get Firefox!
<http://www.spreadfirefox.com/commun...es&id=2885&t=85>|
Reclaim Your Inbox! <http://www.mozilla.org/products/thunderbird>


LJ Wilkinson wrote:

>Hi,
>
>I have a question about validation when grouping elements in an
>HTML_Quickform. Here's 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 doesn't create nested arrays when
>filling out the $_POST array: it's 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 doesn't 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 I'm not supposed to do that.
>
>I'd 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
>
>


LJ Wilkinson

2005-05-04, 8:57 pm

Brilliant! I wasn’t aware that that parameter existed. Thanks!

-----Original Message-----
From: Matte Edens [mailto:matte@arubanetworks.com]
Sent: Wednesday, May 04, 2005 12:07 PM
To: LJ Wilkinson
Cc: pear-general@lists.php.net
Subject: Re: [PEAR] QuickForm element group validation question

In your "addGroup()" call, I think you might want to set a name for your
group but set the $appendName parameter to false. I think that'll do what
you want it to do. Keep it flat but still referencable inside the
addGroupRule() function.

see the description of the parameters for the addGroup() rule at the
following url.

<http://pear.php.net/manual/en/packa...ml-quickform.ad
dgroup.php>
<http://pear.php.net/manual/en/packa...ml-quickform.ad
dgroup.php>
matte - matte@arubanetworks.com <mailto:matte@arubanetworks.com>
webmonkey » arubanetworks.com <http://www.arubanetworks.com>
Get Firefox!
<http://www.spreadfirefox.com/commun...es&id=2885&t=85> |
Reclaim Your Inbox! <http://www.mozilla.org/products/thunderbird>


LJ Wilkinson wrote:
Hi,

I have a question about validation when grouping elements in an
HTML_Quickform. Here's 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 doesn't create nested arrays when
filling out the $_POST array: it's 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 doesn't 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 I'm not supposed to do that.

I'd 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


Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com