RE: [PEAR] QuickForm, Groups an getElement
| From: | Sönke Ruempler | Date: | Wed, 06 Oct 2004 05:55:32 +0000 |
| Subject: | RE: [PEAR] QuickForm, Groups an getElement | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-14770@lists.php.net to get a copy of this message | ||
Sönke Ruempler <mailto:ruempler@topconcepts.com> wrote on Tuesday,
October
05, 2004 10:35 AM:
> Is there any possibilty to get a reference to an element
> object that is
> inside a group?
>
> I just found "$group->getElements()", but it returns a
> numeric array and i
> want to get the element (reference) by it's name,
> "$form->getElement('name')" only works for non-grouped elements.
I hope there is a Quickform Resolution for this, but for now i wrote my own
function/method (PHP5):
final public function qfGetGroupElement($formName, $groupName, $elementName)
{
$elements =
$this->forms[$formName]->getElement($groupName)->getElements();
foreach ($elements as $element) {
if ($element->getName() == $elementName) {
return $element;
}
}
return NULL;
}