Re: Modify Default QuickForm Template
| From: | Jim Tom Polk | Date: | Sun, 28 Nov 2004 00:36:03 +0000 |
| Subject: | Re: Modify Default QuickForm Template | ||
| References: | 1 2 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15861@lists.php.net to get a copy of this message | ||
Doug, you saved me from defeat! I am able to make changes.
Thank you.
I gather from this then that there is no way to continue using..
$form->display();
...by there being a method to change one of those four variables without using the QuickForm.php and Renderer/Default? I was hoping for something that would be like:
$form->setHeaderTemplate($headerTemplateVariable);
$form->display;
Where $headerTemplateVariable would be from a file that someone could adjust the headerTemplate code separate from editing Default.php, thus allowing for a simple one liner to make the change.
I'm trying for the second time this year to write some extensions that would allow drag, drap and inspect usage of PEAR DB, QuickForm, Mail, Pager and Table. I have to figure a way to be able to have the same code display when someone accepts the default renderer and then when someone wants to alter the template.
This does it, but I'm going to have to rewrite a few things, and that is a pain since the way I'm modifying the code is using JavaScript regex, plus it adds a lot of lines of code...and I'm trying to keep that to a minimum for starters.
I personally just edit the Default.php file and simply pull the changes from a prior version and slap it in...
Again, thanks.
Doug Kearns wrote:
On Sat, Nov 27, 2004 at 01:04:13AM -0600, Jim Tom Polk wrote:After almost 2 hours, I admit defeat. How do you change the the form template without going into HTML/QuickForm/Renderer/Default.php file and adjusting $_headerTemplate, $_elementTemplate, $_formTemplate and $_requiredNoteTemplate?Have a look at: http://pear.php.net/manual/en/package.html.html-quickform.php#package.html.html-quickform.output.basic-renderers <?php require_once 'HTML/QuickForm.php'; require_once 'HTML/QuickForm/Renderer/Default.php'; $form = new HTML_QuickForm(); $form->addElement('header', null, 'Sample Header'); $renderer = &new HTML_QuickForm_Renderer_Default(); $renderer->setHeaderTemplate('<h2>{header}</h2>'); $form->accept($renderer); echo $renderer->toHtml(); ?> <snip> Regards, Doug