There is a standard or a good practice on choosing the name
attribute value in complex HTML form input
elements?
For example:
<input type="text" name="post[comments][0][author][name]" />
But what about multiple values? Should I use
<input type="file" multiple name="post[attachments]" />
or
<input type="file" multiple name="post[attachments][]" />
?
PHP supports only the latter, but W3C uses the former in their examples. Since I'm parsing raw multipart/form-data
entities, I don't rely on a specific language; I'm looking for standards, best practices or suggestions.
The HTML5 spec doesn’t define any format or best practices for the content of the name
attribute. It only reserves the two values isindex
and _charset_
.
(UPDATE: HTML5 defines field name keywords for the autocomplete
attribute.)
For e-commerce forms, there is RFC 3106: ECML v1.1: Field Specifications for E-Commerce. It defines several keywords that can be used as name
values for the input
element (according to section 2.2).
In http://wiki.whatwg.org/wiki/Autocomplete_Types it is explained why this is not a good way to achieve autocomplete functionality:
RFC 3106 requires websites to conform to a set of input naming standards, effectively co-opting the
name
attribute — which has other, sometimes conflicting, uses.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With