Re: QuickForm: group elements and removeElement
| From: | Julie dot L dot Knoll at stls dot frb dot org | Date: | Thu, 25 Sep 2003 19:50:00 +0000 |
| Subject: | Re: QuickForm: group elements and removeElement | ||
| Groups: | php.pear.general | ||
| Request: | Send a blank email to pear-general+get-8047@lists.php.net to get a copy of this message | ||
Thanks for the reply. I tried both methods and neither seemed to work
exactly right.
The first method that sets the elements after validate() is called doesn't
work because the fields are then missing when I try to add validation
rules.
The second method worked okay by unsetting the elements except then I got
an extra label on the form:
Category:
Category: Weekly Releases
I tried unsetting the elements directly using unset($group->_elements[1]),
and not surprisingly I got the same result. So then I tried having a
group with just one element to begin with and got the same thing again.
Apparently it doesn't like having a group with only one element. I'm
using this with the DynamicIT renderer, so maybe its a problem with that?
Thanks Again.
Bertrand Mansion <bmansion@mamasam.com>
09/25/2003 12:36 PM
To: <Julie.L.Knoll@stls.frb.org>, <pear-general@lists.php.net>
cc:
Subject: Re: [PEAR] QuickForm: group elements and removeElement
<Julie.L.Knoll@stls.frb.org> wrote :
> Is there anyway to remove only one element within a group? I know that
> removeElement will not work as it looks for the element name in
> _elementIndex which only contains the name of the group and not the
> elements within a group.
>
> I have the following code:
>
> $category[] =& HTML_QuickForm::createElement('text' , 'category' ,
> 'Category: ' , array('size' => 25 , 'maxlength' => 254));
> $category[] =& HTML_QuickForm::createElement('link' , 'browseCategory'
> ,
> null , '#' , 'Browse' , "onclick=\"newWin =
>
window.open('categoryForm.php','small','width=300,height=300,toolbar=0,status=
> 0,scrollbars=1');\"");
> $category[] =& HTML_QuickForm::createElement('link' , 'addCategory' ,
null
> , '#' , 'Add New' , "onclick=\"newWin =
>
window.open('../category/update.php?opener=1','small','resizable=1,toolbar=0,s
> tatus=1,scrollbars=1');\"");
>
> $form->addGroup($category , 'categoryGroup' , 'Category: ' ,
> ' | ' , 0);
>
> After I validate the form, I use freeze() to show a confirmation page to
> the user, but I would like to remove the two links after the text box.
>
> Any Suggestions?
Looks like there is no direct solution yet, sorry.
You can maybe try (not tested) :
$group =& $form->addGroup(null, 'categoryGroup' , 'Category: ');
Then later after having set $category with the elements you need,
$group->setElements($category);
Or,
$group =& $form->addGroup($category, 'categoryGroup' , 'Category: ' ,
' | ' , 0);
Then after validate(),
$category =& $group->getElements();
unset($category[2]);
unset($category[1]);
A removeElement() method in HTML_QuickForm_group might be an easier
solution
but it doesn't exist.
HTH
Bertrand Mansion
Mamasam
--
PEAR General Mailing List (http://pear.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php