On Tue, Jun 24, 2008 at 6:28 AM, Jörn Zaefferer <
[EMAIL PROTECTED]> wrote:

>
> How about indexing those names?


That would indeed work (if potentially be a bit cumbersome). I have an idea,
though, for how you could support names like "date[]":
Assumptions:
 - You have several inputs with the same name
 - These inputs are part of a collection, so all of their values are
intended to be submitted (and thus need to be validated)
 - All of these inputs have the exact same validation rules applied to them

I propose a new config option called "multi". The value of this option would
be a list of input names that are associated with a collection of form
fields.

As a convenience to the developer, if, when searching for elements to
validate, you come across an input whose name ends in "[]" (or is a
"select-multiple", since the basic logic of this idea could apply to them as
well), the input would be automatically added to the "multi" list.

When validating the input, a check would be made to see if the input's name
is in the "multi" list. If it's not, then validation continues as it always
has. If the element's name is in the "multi" list, then you would collect
all of the values for all of the inputs with that name and run through the
validation rules you have for that input name on each of those values.

-- 
Aaron Heimlich
Web Developer
[EMAIL PROTECTED]

Reply via email to