Re: QFC - how do you validate and then buildForm() ?
| From: | Alexey Borzov | Date: | Fri, 25 Feb 2005 19:53:57 +0000 |
| Subject: | Re: QFC - how do you validate and then buildForm() ? | ||
| References: | 1 2 3 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-17687@lists.php.net to get a copy of this message | ||
Hi,
Matt Flaherty wrote:
I fail to see the usefulness of this method: if you are just adding or removing a handful of elements, you can use removeElement() and insertElementBefore() in the handler for your action. If you are creating a completely different form, you should really use a different class for that.I suggest making *two* different pages, triggered by this particular action. IIRC, there is an example for this in QFC.Thanks. That's a good suggestion. My QuickForm has fields dynamically added to or removed from it as a result of a custom action handler, so that would not work (unless I have misunderstood). Here's the solution I came up with as a method on a class extending HTML_QuickForm_Page: ----%<---- function rebuildForm() {if ($this->isFormBuilt() ) { $this->_formBuilt = false; $pageName = $this->getAttribute('id');// get the automagical form elements $trackSubmitElem =& $this->_elements[$this->_elementIndex["_qf__{$pageName}"] ]; $defaultElem =& $this->_elements[$this->_elementIndex["_qf_default"] ];$this->_elements = array(); $this->_elementIndex = array(); $this->addElement($trackSubmitElem); $this->addElement($defaultElem); } return $this->buildForm();} ----%<---- I've found this does the trick nicely.