Re: FW: FormBuilder - cannot create extra buttons

From: Date: Sat, 05 Nov 2005 05:07:15 +0000
Subject: Re: FW: FormBuilder - cannot create extra buttons
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-21804@lists.php.net to get a copy of this message
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

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