RE: [PEAR-DEV] HTML_QuickForm
| From: | Stig S. Bakken | Date: | Fri, 22 Nov 2002 22:49:04 +0000 |
| Subject: | RE: [PEAR-DEV] HTML_QuickForm | ||
| References: | 1 | Groups: | php.pear.dev |
| Request: | Send a blank email to pear-dev+get-11019@lists.php.net to get a copy of this message | ||
Hi,
With setElementTemplate() you end up putting HTML in your code, which is
one of the things at least I want to avoid when using form generators
and templates in the first place.
I believe what Tony Bibbs meant was to integrate HTML_QuickForm with for
example HTML_Template_IT. So instead of the generic
setElementTemplate() below, it could offer something like this:
$tpl = new HTML_Template_IT($my_template_dir);
$form->setTemplateObject($tpl);
$form->addTemplateElement('select.tpl', 'select', 'foo', $options)
(use the select.tpl template file when displaying this select box)
...or as in Tony's example where you make a template and want the form
generator to set template variables, and then have the template object,
not the form object, actually display the form.
It would be cool if we were able to come up with a "least common
denominator" API that could be implemented by all template systems to
make them all pluggable in packages such as HTML_QuickForm (I'm not
talking about a "template abstraction layer", but about interfaces
implemented by the template packages themselves).
- Stig
On Fri, 2002-11-22 at 16:48, David Sklar wrote:
> You can do this with the setElementTemplate() method, e.g.:
>
>
> $form->setElementTemplate('<TR><TD>{label}:</TD><TD>{element}</TD></TR>');
>
> Also check out the setHeaderTemplate() and setFormTemplate() methods and the
> _headerTemplate, _elementTemplate, and _formTemplate variables in the
> HTML_QuickForm class.
>
> -dave
>
> > -----Original Message-----
> > From: Tony Bibbs [mailto:tony@tonybibbs.com]
> > Sent: Friday, November 22, 2002 10:40 AM
> > To: PEAR Development
> > Subject: [PEAR-DEV] HTML_QuickForm
> >
> >
> > Has there been any thought to allowing the HTML_QuickForm to
> > allow the use
> > of PEAR's HTML template system?
> >
> > What I am getting at is QuickForm appears to have 95% of what I
> > want but I
> > still want to allow people to control the layout of the form. For
> > example, in the templates you'd have something like:
> >
> > <HTML>
> > <BODY>
> > <H2>My Form</H2>
> > {form_start}
> > <TABLE>
> > <TR>
> > <TD>{form_username_label}:</TD><TD>{form_username}</td>
> > </TR>
> > <TR>
> > <TD>{form_password_label}:</TD><TD>{form_password}</td>
> > </TR>
> > </TABLE>
> > {form_end}
> >
> > In this example, all the form_ variables would be set by
> > QuickForm display
> > method. I think this would be pretty easy, first you'd need one method
> > called setOutputType($type) where $type would be some one of two
> > constants, OUTPUT_DEFAULT or OUTPUT_TEMPLATE. OUTPUT_DEFAULT would cause
> > QuickForm to work as it does today and OUTPUT_TEMPLATE would use the PEAR
> > template method out outlined above.
> >
> > Thoughts?
> >
> > --Tony
> >
> >
> > --
> > PEAR Development Mailing List (http://pear.php.net/)
> > To unsubscribe, visit: http://www.php.net/unsub.php
>