RE: [PEAR] FW: FormBuilder - cannot create extra buttons

From: Date: Sat, 05 Nov 2005 07:39:41 +0000
Subject: RE: [PEAR] FW: FormBuilder - cannot create extra buttons
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21806@lists.php.net to get a copy of this message
So much simpler.... thanks Dan. Thanks also Justin for the explanation. It helped put things in perspective. -----Original Message----- From: Dan Rossi [mailto:pear@electroteque.org] Sent: Saturday, 5 November 2005 5:46 PM To: papercrane@reversefold.com Cc: pear-general@lists.php.net; prue@clipmagic.com.au Subject: Re: [PEAR] FW: FormBuilder - cannot create extra buttons I always add the extra elements after returning back the QF object with getForm ie $this->form = $fb->getForm(); $this->form->addElement ... On 05/11/2005, at 4:07 PM, Justin Patrin wrote: > On 11/4/05, Prue <prue@clipmagic.com.au> wrote: >> Dont worry, I worked it out using the postGenerateForm callback. >> >> >> -----Original Message----- >> From: Prue [mailto:prue@clipmagic.com.au] >> Sent: Saturday, 5 November 2005 9:51 AM >> To: 'pear-general@lists.php.net' >> Subject: FormBuilder - cannot create extra buttons >> >> >> Hello >> >> I am using a combination of QF, FB and Smarty to create my forms. >> The basic >> forms work fine with a couple of tweaks for Smarty, eg the header >> variable >> in the template must be called as {$form.header.0} and the submit >> button >> must be called as {$form.__submit__.html} cos that's just the way it >> is with >> Smarty. >> >> My current problem is that I cannot create any other buttons, in >> particular >> a "reset" button. This my the code: >> >> <snip> >> >> $builder -> createSubmit = 1; >> >> $el = HTML_QuickForm::createElement('reset', 'btnClear', >> 'Clear'); >> $builder -> preDefElements['btnClear'] = $el; >> >> </snip> >> >> The FB createSubmit works but the reset button element is ignored. >> I've >> checked the $form array before it's rendered to the Smarty array and >> there >> is no reference to the btnClear element which points to something >> wrong with >> my FB/QF code. If I choose addElement rather than createElement I >> get the >> following QF error: >> "Fatal error: Using $this when not in object context in >> c:\www\myownproject\include\PEAR\HTML\QuickForm.php on line 602" >> > > addElement() only works on an instance. You can't call it statically. > > In addition, preDefElement is *only* used to replace auto-generated > elements with custom generated ones. You can't add elements with it > (unless you create a virtual field which is not the best solution). > Your best bet is to add the element in postGenerateForm or in your > calling script after you getForm(). > > -- > Justin Patrin > > -- > PEAR General Mailing List (http://pear.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > -- PEAR General Mailing List (http://pear.php.net/) To unsubscribe, visit: http://www.php.net/unsub.php

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