Re: html_quickform_renderer

From: Date: Fri, 05 Mar 2010 16:05:38 +0000
Subject: Re: html_quickform_renderer
References: 1 2 3  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-30368@lists.php.net to get a copy of this message
Ok so the basic idea is that the form, element all have various "templates", for example this is the basic element (element being a input, select) template: "\n\t<tr>\n\t\t<td align=\"right\" valign=\"top\"><!-- BEGIN required --><span style=\"color: #ff0000\">*</span><!-- END required --><b>{label}</b></td>\n\t\t<td valign=\"top\" align=\"left\"><!-- BEGIN error --><span style=\"color: #ff0000\">{error}</span><br /><!-- END error -->\t{element}</td>\n\t</tr>" You can see the place holders for the element {element}, errors, etc. To edit an elements template (say you want to remove the table structure and wrap the element in a div) you can do it in the following manner: // instantiate quickform $form = new HTML_QuickForm('orderForm' ); // get the forms default renderer $renderer =& $form->defaultRenderer(); // create an element $form->addElement( 'text', 'test', 'Test Element' ); // my new form element template $newTemplate = "<div class="newClass">{error}{element}{label}</div>"; // apply template to specific element $renderer->setElementTemplate($newTemplate, 'test'); // to apply to all ememnets $renderer->setElementTemplate($newTemplate); Note you can of course just use css to target the various elements or you can add classes/ids without editing the template $form->addElement( 'text', 'test', 'Test Element', array( 'class'=>'newClass', 'id' => 'myId' ) ); Not sure if that is what you were looking for. MS On Fri, Mar 5, 2010 at 12:04 AM, Andrea Bakker <abakker@telkomsa.net> wrote: > I'm trying to find a way to customize the look of the quickform by using an > external css.   It looks like quickform_renderer is the way to go. But I > can't find a good example on how to implement this. > > ----- Original Message ----- From: "Mark Steudel" <msteudel@gmail.com> > To: "Andrea Bakker" <abakker@telkomsa.net> > Cc: "pear general" <pear-general@lists.php.net> > Sent: Thursday, March 04, 2010 5:28 PM > Subject: Re: [PEAR] html_quickform_renderer > > > I'm curious what are you trying to do? > > MS > > On Thu, Mar 4, 2010 at 4:25 AM, Andrea Bakker <abakker@telkomsa.net> wrote: >> >> Hi >> >> I've been searching for hours to try and find a simple example on how to >> implement html_quickform_renderer in conjunction with an external >> stylesheet. Can you suggest a good link. >> >> Thanks >> Andrea > > > > -- > > ----------------------------------------- > Mark Steudel > P: 206.375.7244 > msteudel@gmail.com > > . : Work : . > http://www.mindfulinteractive.com > > . : Play : . > http://www.steudel.org/blog > > -- ----------------------------------------- Mark Steudel P: 206.375.7244 msteudel@gmail.com . : Work : . http://www.mindfulinteractive.com . : Play : . http://www.steudel.org/blog

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