Re: adding class to td in HTML_Quickform

From: Date: Thu, 27 Apr 2006 17:19:15 +0000
Subject: Re: adding class to td in HTML_Quickform
References: 1  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23863@lists.php.net to get a copy of this message
On 4/27/06, Michael Larocque <mlarocque@prolumina.com> wrote: > Hi all, > > I'm relatively new to PEAR. My first usage involves HTML_Quickform. > I'm using it to create a very simple form. > > The following php snippet: > > parent::HTML_QuickForm('formContact', 'post'); > $this->addElement('text', 'name', 'Name'); > $this->addRule('name', 'A name is required', > 'required'); > ... > > produces the following html snippet: > > <tr> > <td align="right" valign="top"><span > style="color: #ff0000">*</ > span><b>Name</b></td> > <td valign="top" align="left"><input > name="name" type="text" /></td> > </tr> > > What I'd like to do is to add a 'class="foo"' to the first td (i.e. > the label) so that I can style it, and optionally remove the 'align' > and 'valign' bits. i.e.: > > <tr> > <td class="foo"><span style="color: > #ff0000">*</span><b>Name</b></td> > <td valign="top" align="left"><input > name="name" type="text" /></td> > </tr> > > Is there a simple way of doing this? Any help greatly appreciated. > Before you output the form: $r =& HTML_QuickForm::defaultRenderer(); $r->setElementTemplate('...', 'name'); Where '...' is the template you want to use. Look in the HTML/QuickForm/Renderer/Default.php for the default element template. -- Justin Patrin

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