WICG / proposals

A home for well-formed proposed incubations for the web platform. All proposals welcome.
https://wicg.io/
Other
227 stars 12 forks source link

Groups of inputs and arrays of groups of inputs in forms #132

Open alejsanc opened 9 months ago

alejsanc commented 9 months ago

Sometimes it is necessary to group several inputs into a single name and other times it is necessary to make arrays of these groups. In the case of arrays, it is also necessary to use a button and javascript to add more groups of inputs. This should be done using HTML only.

Group of inputs now
------------------------------
<input type="text" name="user:name" />
<input type="email" name="user:email" />

Array of groups of inputs now
--------------------------------------------
<input type="text" name="user:0:name" />
<input type="email" name="user:0:email" />

<input type="text" name="user:1:name" />
<input type="email" name="user:1:email" />

<button>Add Inputs Group</button>
How it should be
-------------------------
<inputs-group name="user">
   <input type="text" name="name" />
   <input type="email" name="email" />
</inputs-group>

<inputs-groups-array name="user">
   <input type="text" name="name" />
   <input type="email" name="email" />
</inputs-groups-array>

The sending to the server could be done with variables or with JSON. And the server's programming language should parse it in classes and arrays.

user:name=Name
user:email=user@domain.tld

user:0:name=Name1
user:0:email=user1@domain.tld
user:1:name=Name2
user:1:email=user2@domain.tld
"user"  :  {
   "name" : "Name",
   "email" : "user@domain.tld"
}

"user"  :  [
   {
       "name" : "Name1",
       "email" : "user1@domain.tld"
   },{
       "name" : "Name2",
       "email" : "user2@domain.tld"
   }
]