开发者

Create multiple email records from one text_field values separated by colon

开发者 https://www.devze.com 2023-04-04 05:45 出处:网络
i have a form like this: <%= form_for @group, :url => { :controller => \"groups\", :action => \"create\" } do |f| %>

i have a form like this:

<%= form_for @group, :url => { :controller => "groups", :action => "create" } do |f| %>
    <%= f.label(:name, "Group Name:") %><br />
    <%= f.text_field(:name) %><br />
    <%= f.fields_for :members, :url => { :controller => "members", :action => "create" } do |builder| %>
         <%= builder.label(:email, "Email Addresses:") %><br />
         <%= builder.text_field(:email) %><br />
    <% end %>
<% end %>

i have setup the nested attributes in my Group.rb model, the form renders fine.

I need the user to type emails separated by a space or colon into the email text field and then in my controller somewhere separate each email address by the colons and store them into the 开发者_C百科database individually.


If you're only going to have a single field for a collection, AFAIK you'd have to break them up manually (split would likely suffice), add each member to the group's members, and save the group.

0

精彩评论

暂无评论...
验证码 换一张
取 消