diff options
author | Josiah Ivey <josiah.ivey@gmail.com> | 2010-05-25 08:03:04 -0500 |
---|---|---|
committer | Josiah Ivey <josiah.ivey@gmail.com> | 2010-05-25 08:03:04 -0500 |
commit | 96e2094b8b634e4af0d9d3c8a1db9bbb7023a4a7 (patch) | |
tree | 6473b8b552cbcb0f7b761cf2ed8ec4c0102e45aa /railties | |
parent | 0855e0404424483e097b2396dc2e54d8f17e74d0 (diff) | |
download | rails-96e2094b8b634e4af0d9d3c8a1db9bbb7023a4a7.tar.gz rails-96e2094b8b634e4af0d9d3c8a1db9bbb7023a4a7.tar.bz2 rails-96e2094b8b634e4af0d9d3c8a1db9bbb7023a4a7.zip |
Form Helpers guide: Use new syntax for fields_for examples
Diffstat (limited to 'railties')
-rw-r--r-- | railties/guides/source/form_helpers.textile | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/railties/guides/source/form_helpers.textile b/railties/guides/source/form_helpers.textile index 0c0a4e2263..515b3aad39 100644 --- a/railties/guides/source/form_helpers.textile +++ b/railties/guides/source/form_helpers.textile @@ -255,7 +255,7 @@ You can create a similar binding without actually creating +<form>+ tags <erb> <%= form_for :person, @person, :url => { :action => "create" } do |person_form| %> <%= person_form.text_field :name %> - <% fields_for @person.contact_detail do |contact_details_form| %> + <%= fields_for @person.contact_detail do |contact_details_form| %> <%= contact_details_form.text_field :phone_number %> <% end %> <% end %> @@ -697,7 +697,7 @@ You might want to render a form with a set of edit fields for each of a person's <%= form_for @person do |person_form| %> <%= person_form.text_field :name %> <% for address in @person.addresses %> - <% person_form.fields_for address, :index => address do |address_form|%> + <%= person_form.fields_for address, :index => address do |address_form|%> <%= address_form.text_field :city %> <% end %> <% end %> @@ -725,7 +725,7 @@ Rails knows that all these inputs should be part of the person hash because you To create more intricate nestings, you can specify the first part of the input name (+person[address]+ in the previous example) explicitly, for example <erb> -<% fields_for 'person[address][primary]', address, :index => address do |address_form| %> +<%= fields_for 'person[address][primary]', address, :index => address do |address_form| %> <%= address_form.text_field :city %> <% end %> </erb> @@ -741,7 +741,7 @@ As a general rule the final input name is the concatenation of the name given to As a shortcut you can append [] to the name and omit the +:index+ option. This is the same as specifying +:index => address+ so <erb> -<% fields_for 'person[address][primary][]', address do |address_form| %> +<%= fields_for 'person[address][primary][]', address do |address_form| %> <%= address_form.text_field :city %> <% end %> </erb> |