Quoting Brett Sanger <[EMAIL PROTECTED]>:

> Basically I want to display for entry/edit multiple sets of data in the
> same form.  This occurs when my users want to enter/edit a large number
> of small pieces of data, and having each set in it's own form would be
> very tedious.
> 
> The problem is how to have the repeating fields so that they play well
> with designers, Data::FormValidator, and HTML::FillInForm.  
> 
> The designer-friendly way is to have the fields with the same names:
> 
> <input name="title">
> <input name="author">
> <hr>
> <input name="title">
> <input name="author">
> ..etc

You can't depend on this, because the action that the browser will take is not
well defined. The browser can submit these values in any order it chooses. 
Usually this is in the order that the elements appear in the form, but this is
not enforced.  

Also what happens if your user only inputs a 'title' in the first entry, and
both the 'title' and 'author' in the second value?  Can you be certain that all
browsers will send the empty 'author' field as well?  If not, then your results
will be scewed.  You won't know which 'title' goes with which 'author'.

The only way I can see to solve this with any consistency is to use numbered
variable names.  With HTML::Template you could use something like this:

<TMPL_LOOP BOOKS>
<input name="title<TMPL_VAR __counter__>">
<input name="author<TMPL_VAR __counter__>">
<input type="hidden" name="index" value="<TMPL_VAR __counter__>">
<hr>
</TMPL_LOOP>

The hidden 'index' field could be ignored, but it will help you on the code side
by giving you an array of indexes that the form defined.

Cees

> 
> We can place this in a loop to repeat N times, and it works great.
> (Note that N might change, for example, I might want to display 6
> entries for new entry, but min(6, #existing+2) to edit existing
> entries.)
> 
> This, however, doesn't play well with Data::FormValidator or
> HTML::FillInForm.  D::FV can't tell the "subforms" apart, so it only
> reports on the page, and H::FIF will repeat any answers to fill in
> multiple blocks.  [The exact problems differ depending on the type of
> form field used...SELECT boxes show different symptoms than input boxes]
> 
> D::FV can be corrected by breaking the input into sets.
> 
> H::FIF really only works if the fields have unique names.  This can be
> done by appending a "number" to the fieldnames, but then the HTML
> becomes much less designer friendly.  (I'm using Template Toolkit, but
> this holds for most any template system I can think of).
> 
> Has anyone else dealt with this?
> 
> -- 
> SwiftOne
> [EMAIL PROTECTED]
> 
> ---------------------------------------------------------------------
> Web Archive:  http://www.mail-archive.com/[email protected]/
> To unsubscribe, e-mail: [EMAIL PROTECTED]
> For additional commands, e-mail: [EMAIL PROTECTED]
> 
> 



---------------------------------------------------------------------
Web Archive:  http://www.mail-archive.com/[email protected]/
To unsubscribe, e-mail: [EMAIL PROTECTED]
For additional commands, e-mail: [EMAIL PROTECTED]

Reply via email to