Re: Building "Advanced Search" like forms using QuickForm
| From: | Justin Patrin | Date: | Fri, 05 Nov 2004 00:49:30 +0000 |
| Subject: | Re: Building "Advanced Search" like forms using QuickForm | ||
| References: | 1 | Groups: | php.pear.general |
| Request: | Send a blank email to pear-general+get-15347@lists.php.net to get a copy of this message | ||
On Wed, 03 Nov 2004 09:06:33 -0500, Ravindra Wankar <rwankar@celoxis.com> wrote:
>
> I've looked at HTML_Quickform and FormBuilder and have a few questions
> regarding its use for non-add/edit forms.
>
If you're not adding/editing, why are you using FB? If you're talking
a general search functionality for any table this could be done with
FB (I've done it), but I don't really see how using FB for non-DB
operations would work.
> I have seen the example using the QuickHtml renderer. Seems like too
> much work for custom forms.
>
> e.g "Advanced Search" form or many times one has "filter" forms
> associated with huge
> amounts of tabular data. Also, if one needs to display an add/edit form
> in a 2-col
> layout (for better space utilization) again I must write my own template.
Well, not necessarily. I've been using 'html' elements and the
equivalent of insertElementBefor() in HTML_QuickForm for a project I'm
working on to break up a form into multiple columns. It's not too
hard.
>
> Basically, you first call addElement() to tell quickform about the
> elements and then use them in a 'template'. The moment I write my own
> template, I have to handle the display of form errors next to elements
> and that becomes a pain for each form. Having to write code in 2 places
> (one where you call addElement() and then the template) also does not
> seem very elegant.
I can understand this. Buth with FB, you don't have to addElement manually....
>
> Any suggestions on doing this?
>
> Has anyone considered the following possibility of doing something like
> what you can do with apache struts (for Java)? Special tags are defined
> for form elements eg
>
> |<P>Username: <html:text property="username"/></P>
>
> When rendering this, the error is automatically shown next to the element. If you want fancy
> formatting, you can get hold of the errors and display them yourself.
>
> This way I don't have to construct form elements using addElement() separately
> and form developers need not worry about displaying error messages.
> The validation rules can be specified at the top template.
>
> One way might be to write an xsl transformer that converts files written like these
> into a format that can then be run thru the QuickHTML renderer. This will add to
> a performance problem as each form has to be parsed twice (once by the pre-processor
> and then by QuickForm). It might be possible to pre-process the templates first but then
> this introduces a "build" step that spoils the fun of being able to simple save files
> and refresh my browser to see the changes (not to mention slowing development).
>
> See http://formsess.sourceforge.net for something similar. It
> is based on smarty. As QuickForm is so popular
> I'd prefer direct support under QuickForm.
>
> Can QuickForm developers add direct support for something like this? Any better ideas?
>
This has been talked about before. I would suggest changing the
ArraySmarty renderer to give you the whole error/element html segment
as one string and writing your smarty template with just that one
string for output of each element.
--
paperCrane --Justin Patrin--