• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 812
  • Last Modified:

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.

Thanks,
Frank
<?php
 
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');
 
$page->addStyleDeclaration('
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())
  {
    $form->freeze();
  }
 
$form->accept($renderer);
$htmlout = $renderer->toHtml();
 
$page->addBodyContent($htmlout);
 
$page->display();
 
?>

Open in new window

0
ibanja
Asked:
ibanja
  • 2
  • 2
1 Solution
 
Steve BinkCommented:
Try something like this:


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

Open in new window

0
 
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.

0
 
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.
0
 
ibanjaAuthor Commented:
routinet,

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

Thanks for the help.  

Frank  
0

Featured Post

Upgrade your Question Security!

Add Premium security features to your question to ensure its privacy or anonymity. Learn more about your ability to control Question Security today.

  • 2
  • 2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now