Re: adding class to td in HTML_Quickform

From: Date: Thu, 27 Apr 2006 18:36:46 +0000
Subject: Re: adding class to td in HTML_Quickform
References: 1 2  Groups: php.pear.general 
Request: Send a blank email to pear-general+get-23866@lists.php.net to get a copy of this message
On 27-Apr-06, at 11:19, Justin Patrin wrote:
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.
Sweet! That did it Justin. Thank you very much! Carpe viam, Mike Michael Larocque Chief Cook and Bottle Washer Prolumina Communications Inc. http://prolumina.com/~mlarocque/

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