Form control names with multiple values

Greetings to everybody.
There's not a lot of research behind my argument, so please help me if I'm
wrong.
The spec correctly says that file upload <input> elements can have
@multiple (along with email and range states).
What it doesn't say is that in some cases (e.g. in PHP) <input type="file"
multiple> allows to represent only 1 file server-side (each file overwrites
the previous one in upload order) unless the control name contains square
brackets, thus allowing the submitted control values to be mapped as an
array.
Of course this does not apply to range and email modes (the other 2 cases
when @multiple is allowed): as far as I tested (Chrome, Opera, FF last
versions):
 - email value is always sent as a single only string, with a comma used as
separator (@multiple only matters for validation);
 - range, on the other hand, has no support for multiple values, so when a
comma is present, the browser simply ignores the whole value altogether and
sets the control in "missing value default" state, i.e 50 (which is the
value sent to the server if no change occurs).
What applies to ALL controls, instead, is this: when names are in "array
mode" (a string followed by square brackets, occasionally containing
another string), all controls with a common "name" (the first string) are
represented as a succession of values in an array, which can be indexed or
associative. To make an example, when POSTing a form with the following
controls (but the same is true for GET):
<input name="foo[]" value="a" />
<input name="foo[]" value="b" />
<input name="foo[bar]" value="c" />
the returned value will be represented this way (example for PHP)
$_POST['foo'] = array(0 => 'a',1 => 'b', 'bar' => 'c')
which can be quite useful in some cases.
Actually value processing relates to server-side submission phase, but
naming controls is a matter of markup.
In short, it would be necessary to:
 1. notify authors of the possibility to set controls in "array mode";
 2. notify authors that they must set file upload control name in "array
mode" if they're going to use @multiple;
 3. decide what to do with multiple emails, but I guess that, for backward
compatibility, an email field with multiple will always return one string;
 4. see whether user agents feel like they're going to support multiple
range (which is new of HTML5.1); in case of positive answer, decide what to
do with multiple ranges (single string or array conversion).
Is that correct? Thanks for the patience.
Andrea Rendine

Received on Sunday, 29 March 2015 01:49:52 UTC