Skip to content

Instantly share code, notes, and snippets.

@amcaplan
Created April 2, 2014 04:38
Show Gist options
  • Save amcaplan/d34f0b701ffa566c15dc to your computer and use it in GitHub Desktop.
Save amcaplan/d34f0b701ffa566c15dc to your computer and use it in GitHub Desktop.
Guest form using person_field
<% @people.each_with_index do |person, index| %>
<div class="row">
<%= f.fields_for(person) do |ff| %>
<%= person_field("Name:#{ff.text_field :name, name: "person[][name]"}") %>
<%= person_field("Email:#{ff.text_field :email, name: "person[][email]"}") %>
<% mp = person.meal_people.where(meal: @meal).first %>
<%= person_field do %>
Relationship:
<%= select_tag(:host_relationship,
options_for_select(['friend','relative','neighbor',
'coworker', 'student','teacher','clergy', 'other'],
[(mp.host_relationship if mp)]),
name: "person[][host_relationship]",
prompt: "Who is s/he to you?") %>
<% end %>
<br>
<%= tag(:hr) unless index == @people.length - 1 %>
<% end %>
</div>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment