aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_helper.rb
diff options
context:
space:
mode:
authorJosé Valim <jose.valim@gmail.com>2011-07-01 14:51:34 -0300
committerJosé Valim <jose.valim@gmail.com>2011-07-01 14:52:18 -0300
commit3da608e0b48b44d695d4727c3dc2a8022fdbddd7 (patch)
tree9da6cba4e90faeda7b3600e6e987f5d3b9330e91 /actionpack/lib/action_view/helpers/form_helper.rb
parent441d8ec13037c90b448769178fb8c3fef40fb74b (diff)
downloadrails-3da608e0b48b44d695d4727c3dc2a8022fdbddd7.tar.gz
rails-3da608e0b48b44d695d4727c3dc2a8022fdbddd7.tar.bz2
rails-3da608e0b48b44d695d4727c3dc2a8022fdbddd7.zip
Revert "Add method fields_for_with_index to FormHelper"
This reverts commit 7c562d5e460d97b18e4f3367b3cfb13401732920. Conflicts: actionpack/lib/action_view/helpers/form_helper.rb
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb24
1 files changed, 6 insertions, 18 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index 41a503982a..9feec04429 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -567,18 +567,13 @@ module ActionView
# ...
# <% end %>
#
- # In addition, you may want to have access to the current iteration index.
- # In that case, you can use a similar method called fields_for_with_index
- # which receives a block with an extra parameter:
+ # When projects is already an association on Person you can use
+ # +accepts_nested_attributes_for+ to define the writer method for you:
#
- # <%= form_for @person do |person_form| %>
- # ...
- # <%= person_form.fields_for_with_index :projects do |project_fields, index| %>
- # Position: <%= index %>
- # Name: <%= project_fields.text_field :name %>
- # <% end %>
- # ...
- # <% end %>
+ # class Person < ActiveRecord::Base
+ # has_many :projects
+ # accepts_nested_attributes_for :projects
+ # end
#
# If you want to destroy any of the associated models through the
# form, you have to enable it first using the <tt>:allow_destroy</tt>
@@ -1233,13 +1228,6 @@ module ActionView
RUBY_EVAL
end
- # Check +fields_for+ for docs and examples.
- def fields_for_with_index(record_name, record_object = nil, fields_options = {}, &block)
- index = fields_options[:index] || options[:child_index] || nested_child_index(@object_name)
- block_with_index = Proc.new{ |obj| block.call(obj, index) }
- fields_for(record_name, record_object, fields_options, &block_with_index)
- end
-
def fields_for(record_name, record_object = nil, fields_options = {}, &block)
fields_options, record_object = record_object, nil if record_object.is_a?(Hash) && record_object.extractable_options?
fields_options[:builder] ||= options[:builder]