coplan Posted March 14, 2007 Share Posted March 14, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/42721-pear-html_quickform-controlling-css/ Share on other sites More sharing options...
coplan Posted March 14, 2007 Author Share Posted March 14, 2007 Any thoughts? Quote Link to comment https://forums.phpfreaks.com/topic/42721-pear-html_quickform-controlling-css/#findComment-207541 Share on other sites More sharing options...
coplan Posted March 16, 2007 Author Share Posted March 16, 2007 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. Quote Link to comment https://forums.phpfreaks.com/topic/42721-pear-html_quickform-controlling-css/#findComment-208918 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.