Skip to content

Commit cf64895

Browse files
authored
Merge pull request rails#50744 from takatea/fix-docs-form_for-to-form_with-in-form_helper
docs: Update FormHelper comments to use `form_with` instead of `form_for` [ci skip]
2 parents 325c04c + 013667f commit cf64895

File tree

1 file changed

+33
-33
lines changed

1 file changed

+33
-33
lines changed

actionview/lib/action_view/helpers/form_helper.rb

Lines changed: 33 additions & 33 deletions
Original file line numberDiff line numberDiff line change
@@ -783,12 +783,12 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
783783
end
784784
end
785785

786-
# Creates a scope around a specific model object like form_for, but
786+
# Creates a scope around a specific model object like form_with, but
787787
# doesn't create the form tags themselves. This makes fields_for suitable
788788
# for specifying additional model objects in the same form.
789789
#
790-
# Although the usage and purpose of +fields_for+ is similar to +form_for+'s,
791-
# its method signature is slightly different. Like +form_for+, it yields
790+
# Although the usage and purpose of +fields_for+ is similar to +form_with+'s,
791+
# its method signature is slightly different. Like +form_with+, it yields
792792
# a FormBuilder object associated with a particular model object to a block,
793793
# and within the block allows methods to be called on the builder to
794794
# generate fields associated with the model object. Fields may reflect
@@ -799,7 +799,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
799799
# both an object name (represented by either a symbol or string) and the
800800
# object itself can be passed to the method separately -
801801
#
802-
# <%= form_for @person do |person_form| %>
802+
# <%= form_with model: @person do |person_form| %>
803803
# First name: <%= person_form.text_field :first_name %>
804804
# Last name : <%= person_form.text_field :last_name %>
805805
#
@@ -880,7 +880,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
880880
#
881881
# This model can now be used with a nested fields_for, like so:
882882
#
883-
# <%= form_for @person do |person_form| %>
883+
# <%= form_with model: @person do |person_form| %>
884884
# ...
885885
# <%= person_form.fields_for :address do |address_fields| %>
886886
# Street : <%= address_fields.text_field :street %>
@@ -910,7 +910,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
910910
# with a value that evaluates to +true+, you will destroy the associated
911911
# model (e.g. 1, '1', true, or 'true'):
912912
#
913-
# <%= form_for @person do |person_form| %>
913+
# <%= form_with model: @person do |person_form| %>
914914
# ...
915915
# <%= person_form.fields_for :address do |address_fields| %>
916916
# ...
@@ -951,7 +951,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
951951
# the nested fields_for call will be repeated for each instance in the
952952
# collection:
953953
#
954-
# <%= form_for @person do |person_form| %>
954+
# <%= form_with model: @person do |person_form| %>
955955
# ...
956956
# <%= person_form.fields_for :projects do |project_fields| %>
957957
# <% if project_fields.object.active? %>
@@ -963,7 +963,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
963963
#
964964
# It's also possible to specify the instance to be used:
965965
#
966-
# <%= form_for @person do |person_form| %>
966+
# <%= form_with model: @person do |person_form| %>
967967
# ...
968968
# <% @person.projects.each do |project| %>
969969
# <% if project.active? %>
@@ -977,7 +977,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
977977
#
978978
# Or a collection to be used:
979979
#
980-
# <%= form_for @person do |person_form| %>
980+
# <%= form_with model: @person do |person_form| %>
981981
# ...
982982
# <%= person_form.fields_for :projects, @active_projects do |project_fields| %>
983983
# Name: <%= project_fields.text_field :name %>
@@ -999,7 +999,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
999999
# parameter with a value that evaluates to +true+
10001000
# (e.g. 1, '1', true, or 'true'):
10011001
#
1002-
# <%= form_for @person do |person_form| %>
1002+
# <%= form_with model: @person do |person_form| %>
10031003
# ...
10041004
# <%= person_form.fields_for :projects do |project_fields| %>
10051005
# Delete: <%= project_fields.check_box :_destroy %>
@@ -1011,7 +1011,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
10111011
# object in the array. For this purpose, the <tt>index</tt> method is
10121012
# available in the FormBuilder object.
10131013
#
1014-
# <%= form_for @person do |person_form| %>
1014+
# <%= form_with model: @person do |person_form| %>
10151015
# ...
10161016
# <%= person_form.fields_for :projects do |project_fields| %>
10171017
# Project #<%= project_fields.index %>
@@ -1220,7 +1220,7 @@ def hidden_field(object_name, method, options = {})
12201220
# hash with +options+. These options will be tagged onto the HTML as an HTML element attribute as in the example
12211221
# shown.
12221222
#
1223-
# Using this method inside a +form_for+ block will set the enclosing form's encoding to <tt>multipart/form-data</tt>.
1223+
# Using this method inside a +form_with+ block will set the enclosing form's encoding to <tt>multipart/form-data</tt>.
12241224
#
12251225
# ==== Options
12261226
# * Creates standard HTML attributes for the tag.
@@ -1629,10 +1629,10 @@ def default_form_builder_class
16291629
#
16301630
# A +FormBuilder+ object is associated with a particular model object and
16311631
# allows you to generate fields associated with the model object. The
1632-
# +FormBuilder+ object is yielded when using +form_for+ or +fields_for+.
1632+
# +FormBuilder+ object is yielded when using +form_with+ or +fields_for+.
16331633
# For example:
16341634
#
1635-
# <%= form_for @person do |person_form| %>
1635+
# <%= form_with model: @person do |person_form| %>
16361636
# Name: <%= person_form.text_field :name %>
16371637
# Admin: <%= person_form.check_box :admin %>
16381638
# <% end %>
@@ -1668,7 +1668,7 @@ def default_form_builder_class
16681668
#
16691669
# The +div_radio_button+ code from above can now be used as follows:
16701670
#
1671-
# <%= form_for @person, :builder => MyFormBuilder do |f| %>
1671+
# <%= form_with model: @person, :builder => MyFormBuilder do |f| %>
16721672
# I am a child: <%= f.div_radio_button(:admin, "child") %>
16731673
# I am an adult: <%= f.div_radio_button(:admin, "adult") %>
16741674
# <% end -%>
@@ -1738,7 +1738,7 @@ def initialize(object_name, object, template, options)
17381738
#
17391739
# return the <tt><form></tt> element's <tt>id</tt> attribute.
17401740
#
1741-
# <%= form_for @article do |f| %>
1741+
# <%= form_with model: @article do |f| %>
17421742
# <%# ... %>
17431743
#
17441744
# <% content_for :sticky_footer do %>
@@ -1760,7 +1760,7 @@ def id
17601760
# Return the value generated by the <tt>FormBuilder</tt> for the given
17611761
# attribute name.
17621762
#
1763-
# <%= form_for @article do |f| %>
1763+
# <%= form_with model: @article do |f| %>
17641764
# <%= f.label :title %>
17651765
# <%= f.text_field :title, aria: { describedby: f.field_id(:title, :error) } %>
17661766
# <%= tag.span("is blank", id: f.field_id(:title, :error) %>
@@ -1781,12 +1781,12 @@ def field_id(method, *suffixes, namespace: @options[:namespace], index: @options
17811781
# Return the value generated by the <tt>FormBuilder</tt> for the given
17821782
# attribute name.
17831783
#
1784-
# <%= form_for @article do |f| %>
1784+
# <%= form_with model: @article do |f| %>
17851785
# <%= f.text_field :title, name: f.field_name(:title, :subtitle) %>
17861786
# <%# => <input type="text" name="article[title][subtitle]"> %>
17871787
# <% end %>
17881788
#
1789-
# <%= form_for @article do |f| %>
1789+
# <%= form_with model: @article do |f| %>
17901790
# <%= f.text_field :tag, name: f.field_name(:tag, multiple: true) %>
17911791
# <%# => <input type="text" name="article[tag][]"> %>
17921792
# <% end %>
@@ -2034,12 +2034,12 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
20342034
end
20352035
end
20362036

2037-
# Creates a scope around a specific model object like form_for, but
2037+
# Creates a scope around a specific model object like form_with, but
20382038
# doesn't create the form tags themselves. This makes fields_for suitable
20392039
# for specifying additional model objects in the same form.
20402040
#
2041-
# Although the usage and purpose of +fields_for+ is similar to +form_for+'s,
2042-
# its method signature is slightly different. Like +form_for+, it yields
2041+
# Although the usage and purpose of +fields_for+ is similar to +form_with+'s,
2042+
# its method signature is slightly different. Like +form_with+, it yields
20432043
# a FormBuilder object associated with a particular model object to a block,
20442044
# and within the block allows methods to be called on the builder to
20452045
# generate fields associated with the model object. Fields may reflect
@@ -2050,7 +2050,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
20502050
# both an object name (represented by either a symbol or string) and the
20512051
# object itself can be passed to the method separately -
20522052
#
2053-
# <%= form_for @person do |person_form| %>
2053+
# <%= form_with model: @person do |person_form| %>
20542054
# First name: <%= person_form.text_field :first_name %>
20552055
# Last name : <%= person_form.text_field :last_name %>
20562056
#
@@ -2099,7 +2099,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
20992099
# name and value parameters are provided and the provided value has the shape of an
21002100
# option Hash. To remove the ambiguity, explicitly pass an option Hash, even if empty.
21012101
#
2102-
# <%= form_for @person do |person_form| %>
2102+
# <%= form_with model: @person do |person_form| %>
21032103
# ...
21042104
# <%= fields_for :permission, @person.permission, {} do |permission_fields| %>
21052105
# Admin?: <%= check_box_tag permission_fields.field_name(:admin), @person.permission[:admin] %>
@@ -2143,7 +2143,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
21432143
#
21442144
# This model can now be used with a nested fields_for, like so:
21452145
#
2146-
# <%= form_for @person do |person_form| %>
2146+
# <%= form_with model: @person do |person_form| %>
21472147
# ...
21482148
# <%= person_form.fields_for :address do |address_fields| %>
21492149
# Street : <%= address_fields.text_field :street %>
@@ -2173,7 +2173,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
21732173
# with a value that evaluates to +true+, you will destroy the associated
21742174
# model (e.g. 1, '1', true, or 'true'):
21752175
#
2176-
# <%= form_for @person do |person_form| %>
2176+
# <%= form_with model: @person do |person_form| %>
21772177
# ...
21782178
# <%= person_form.fields_for :address do |address_fields| %>
21792179
# ...
@@ -2214,7 +2214,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
22142214
# the nested fields_for call will be repeated for each instance in the
22152215
# collection:
22162216
#
2217-
# <%= form_for @person do |person_form| %>
2217+
# <%= form_with model: @person do |person_form| %>
22182218
# ...
22192219
# <%= person_form.fields_for :projects do |project_fields| %>
22202220
# <% if project_fields.object.active? %>
@@ -2226,7 +2226,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
22262226
#
22272227
# It's also possible to specify the instance to be used:
22282228
#
2229-
# <%= form_for @person do |person_form| %>
2229+
# <%= form_with model: @person do |person_form| %>
22302230
# ...
22312231
# <% @person.projects.each do |project| %>
22322232
# <% if project.active? %>
@@ -2240,7 +2240,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
22402240
#
22412241
# Or a collection to be used:
22422242
#
2243-
# <%= form_for @person do |person_form| %>
2243+
# <%= form_with model: @person do |person_form| %>
22442244
# ...
22452245
# <%= person_form.fields_for :projects, @active_projects do |project_fields| %>
22462246
# Name: <%= project_fields.text_field :name %>
@@ -2262,7 +2262,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
22622262
# parameter with a value that evaluates to +true+
22632263
# (e.g. 1, '1', true, or 'true'):
22642264
#
2265-
# <%= form_for @person do |person_form| %>
2265+
# <%= form_with model: @person do |person_form| %>
22662266
# ...
22672267
# <%= person_form.fields_for :projects do |project_fields| %>
22682268
# Delete: <%= project_fields.check_box :_destroy %>
@@ -2274,7 +2274,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
22742274
# object in the array. For this purpose, the <tt>index</tt> method
22752275
# is available in the FormBuilder object.
22762276
#
2277-
# <%= form_for @person do |person_form| %>
2277+
# <%= form_with model: @person do |person_form| %>
22782278
# ...
22792279
# <%= person_form.fields_for :projects do |project_fields| %>
22802280
# Project #<%= project_fields.index %>
@@ -2562,7 +2562,7 @@ def file_field(method, options = {})
25622562
# Add the submit button for the given form. When no value is given, it checks
25632563
# if the object is a new resource or not to create the proper label:
25642564
#
2565-
# <%= form_for @article do |f| %>
2565+
# <%= form_with model: @article do |f| %>
25662566
# <%= f.submit %>
25672567
# <% end %>
25682568
#
@@ -2595,7 +2595,7 @@ def submit(value = nil, options = {})
25952595
# Add the submit button for the given form. When no value is given, it checks
25962596
# if the object is a new resource or not to create the proper label:
25972597
#
2598-
# <%= form_for @article do |f| %>
2598+
# <%= form_with model: @article do |f| %>
25992599
# <%= f.button %>
26002600
# <% end %>
26012601
# In the example above, if <tt>@article</tt> is a new record, it will use "Create Article" as

0 commit comments

Comments
 (0)