For Programmers: Free Programming Magazines  


Home > Archive > PHP Pear > November 2004 > Re: [PEAR] Modify Default QuickForm Template









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author Re: [PEAR] Modify Default QuickForm Template
Doug Kearns

2004-11-27, 8:55 am

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/packa...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
Jim Tom Polk

2004-11-27, 9:03 pm

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($headerTemplateVariabl
e);
$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:
>
>
>
> Have a look at:
> http://pear.php.net/manual/en/packa...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

Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com