I think your proposal looks good. It'd be nice for us to support this feature.
Please submit a PR and ping me on GitHub so I can take a look. Thank you, Prem On Wednesday, August 22, 2018 at 10:13:28 AM UTC+9, Steve Hoeksema wrote: > > I'm proposing an enhancement per the contribution guidelines, and looking > to find out whether this patch might be accepted. > > HTML5 added the "multiple" attribute > <https://developer.mozilla.org/en-US/docs/Web/HTML/Element/input/email#Allowing_multiple_email_addresses> > > to <input type="email" /> fields. This is useful as it means the user > agent can perform email validation and strip whitespace. > > However, the actual emails are submitted to the server as a > comma-separated string. > > Additionally, Rails magic turns something like > > <%= f.email_field :emails, multiple: true %> > > into > > <input type="email" name="emails[]" multiple /> > > When submitted, we actually receive this: > > params[:emails][0] = "foo,bar" > > But we actually want this: > > params[:emails] = ["foo", "bar"] > > I'm proposing a patch to handle some or all of this unusual (but standards > based) behaviour. > > When rendering an :email_field with the multiple property: > > - When the ActiveModel attribute is an Array, the <input> value should > be joined into a string separated by commas. > - Alternatively, the value should be absent, and a <datalist> should > be added to the output > - Don't append [] to the <input> name, so the form value remains a > string rather than an array of strings > - Append a hidden form input to indicate the Rails should interpret > that form value as a comma-separated string, and turn it into an array > > -- You received this message because you are subscribed to the Google Groups "Ruby on Rails: Core" group. To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-core+unsubscr...@googlegroups.com. To post to this group, send email to rubyonrails-core@googlegroups.com. Visit this group at https://groups.google.com/group/rubyonrails-core. For more options, visit https://groups.google.com/d/optout.