aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--actionpack/lib/action_view/helpers/form_helper.rb8
1 files changed, 8 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_helper.rb b/actionpack/lib/action_view/helpers/form_helper.rb
index e4b90e42f2..32233d26d6 100644
--- a/actionpack/lib/action_view/helpers/form_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_helper.rb
@@ -45,6 +45,14 @@ module ActionView
# <input type="submit" value="Save">
# </form>
#
+ # If the object name contains square brackets the id for the object will be inserted. Example:
+ #
+ # <%= textfield "person[]", "name" %>
+ #
+ # ...becomes:
+ #
+ # <input type="text" id="person_<%= @person.id %>_name" name="person[<%= @person.id %>][name]" value="<%= @person.name %>" />
+ #
# If the helper is being used to generate a repetitive sequence of similar form elements, for example in a partial
# used by render_collection_of_partials, the "index" option may come in handy. Example:
#