Re: QuickForm: group elements and removeElement

From: Date: Thu, 25 Sep 2003 17:36:43 +0000
Subject: Re: QuickForm: group elements and removeElement
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-8046@lists.php.net to get a copy of this message
<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: ' , > '&nbsp;|&nbsp;' , 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: ' , '&nbsp;|&nbsp;' , 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

« previous php.pear.general (#8046) next »