Jump to content

Recommended Posts

Just a quick question that probably has a simple answer, yet I can't find a solution on the Pear website.  I want to have full control on the DEFAULT appearance of the forms outputted by the HTML_QuickForm pear module.  How would I best handle that? 

 

For example, a simple code like this:

  <?php
      require_once "HTML/QuickForm.php";

      $form = new HTML_QuickForm('frmTest', 'get');
      $form->addElement('header', 'MyHeader', 'Testing QuickForm');
      $form->display();
  ?>

 

Yields in HTML like this:

<table border="0">
<tr>
<td style="white-space: nowrap; background-color: #CCCCCC;" align="left" valign="top" colspan="2"><b>Testing QuickForm</b></td>
</td>
</tr>
</table>

 

Ideally, I'd like to be able to assign default CLASS associations instead of the inline style.  I would even be happy just removing the inline style elements.

 

Anyone know how I can control that?  Again, I want to control the DEFAULT behavior.

Link to comment
https://forums.phpfreaks.com/topic/42721-pear-html_quickform-controlling-css/
Share on other sites

took me a really long time to figure it out, but I discovered the $form->defaultRenderer() function (doc).  This gave me access to the setElementTemplate(), setFormTemplate() and setHeaderTemplate().  (among others). 

 

The documentation for those elements wasn't so clear at first, and I was having a lot of trouble because I didn't use the defaultRenderer() function, so I was getting errors.  Now I can clearly change everything once and for all. 

 

An alternative to all this is to use the toArray() method (or some of the Smarty Array methods) and design your own templates with Smarty (or other template engines).  But the toHtml() method is a lot  cleaner and easier if you don't need anything too complicated. 

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.