Re: QF custom element creation
| From: | Alexey Borzov | Date: | Tue, 02 Sep 2003 13:33:16 +0000 |
| Subject: | Re: QF custom element creation | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-7537@lists.php.net to get a copy of this message | ||
Hi!
Mike Carter wrote:
I was thinking of attempting to wrap up some small html/javascript things I'd written into Quickform elements. The single elements don't look too complex, I just wondered if anybody has written a HOWTO for creating a new element from scratch. What classes do what, and maybe a little on the Quickform event mechanism maybe?I was planning to do such a guide for official QuickForm docs, but haven't yet done this. :[ Basically you'll need to consult QuickForm/element.php --- base class for all elements QuickForm/group.php --- group element, I presume you'll base your elements on this and QuickForm/advcheckbox.php QuickForm/date.php QuickForm/hierselect.php which can be considered as examples of custom elements You'll basically need to make sure that all public methods of HTML_QuickForm_element work for your element. As for the event model, we have 4 events now: updateValue: sent when an element has to find a new value for itself among submitted, default and constant values. addElement: sent on adding the element to the form, it basically has to perform createElement and updateValue createElement: sent on element creation, basically just calls its constgructor. there is a need for such an action as different elements have quite different numbers of constructor parameters. setGroupValue: set the element's value to the given parameter (sent to elements within a group via its setValue() method). Look at onQuickFormEvent() method in element.php I suggest you to try implementing something and then post the arising questions to the list. This will greatly help the "writing your elements guide".