Pear QuickForms -- How do I integrate CSS?

I'm working my way through PEAR and using the QuickForms.  I have only been working with PEAR for a few days now.

How can I change element classes?  All the elements are labeled 'class="element"'.  What if I want 'class="address"'?

Also, is there a way to stick in a div or span tag?

It would seem there has to be a way to integrate CSS style sheets, but I can't find it.

I've attached the code I'm working with.  I want to be able to make the address textarea separate from the rest of the elements so I can position it to the right of the name, phone, email fields.

require_once 'HTML/Page2.php';
require_once 'HTML/QuickForm.php';
require_once 'HTML/QuickForm/Renderer/Tableless.php';
$page = new HTML_Page2();
$page->setTitle('Personal Information Form');
div.table {
    border: 1px solid #000;
li { 
display: inline;
$renderer =& new HTML_QuickForm_Renderer_Tableless();
$form =& new HTML_QuickForm('PersonalInfo');
$form->addElement('header', null, 'Personal Information Form');
$intro = "Hi, this is the intro.<p>";
$form->addElement('static', '', '', $intro);
$form->addElement('text', 'name', 'Name', array('size' => 50, 'maxlength' => 255));
$form->addElement('text', 'phone', 'Phone', array('size' => 50, 'maxlength' => 255));
$form->addElement('text', 'email', 'Email', array('size' => 50, 'maxlength' => 255));
$form->addElement('textarea', 'address', 'Address', array('wrap' => 'virtual', 'rows' => 8, 'cols' => 50));
if ($form->validate())
$htmlout = $renderer->toHtml();

Open in new window

Who is Participating?
Steve BinkCommented:
The API documentation does not appear to support that depth of control.  To move forward with this, you'll be digging into the class code for QuickForms and the Renderer.  You could certainly extend the code to do exactly what you want, but this will not be a quick fix.
Steve BinkCommented:
Try something like this:

$form->addElement('textarea', 'address', 'Address', array('wrap' => 'virtual', 'rows' => 8, 'cols' => 50, 'class' => 'address'));

Open in new window

ibanjaAuthor Commented:
Thanks routinet,

I've tried that.  I should have been more clear... I wanted to have more control over the "li" or "label" tags that are generated.  Also, i wanted to add div and span tags.

ibanjaAuthor Commented:

Yep, I think I'm going to write my own class, or possibly extend existing classes.

Thanks for the help.  

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.