@@ -783,12 +783,12 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
783
783
end
784
784
end
785
785
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
787
787
# doesn't create the form tags themselves. This makes fields_for suitable
788
788
# for specifying additional model objects in the same form.
789
789
#
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
792
792
# a FormBuilder object associated with a particular model object to a block,
793
793
# and within the block allows methods to be called on the builder to
794
794
# 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
799
799
# both an object name (represented by either a symbol or string) and the
800
800
# object itself can be passed to the method separately -
801
801
#
802
- # <%= form_for @person do |person_form| %>
802
+ # <%= form_with model: @person do |person_form| %>
803
803
# First name: <%= person_form.text_field :first_name %>
804
804
# Last name : <%= person_form.text_field :last_name %>
805
805
#
@@ -880,7 +880,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
880
880
#
881
881
# This model can now be used with a nested fields_for, like so:
882
882
#
883
- # <%= form_for @person do |person_form| %>
883
+ # <%= form_with model: @person do |person_form| %>
884
884
# ...
885
885
# <%= person_form.fields_for :address do |address_fields| %>
886
886
# Street : <%= address_fields.text_field :street %>
@@ -910,7 +910,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
910
910
# with a value that evaluates to +true+, you will destroy the associated
911
911
# model (e.g. 1, '1', true, or 'true'):
912
912
#
913
- # <%= form_for @person do |person_form| %>
913
+ # <%= form_with model: @person do |person_form| %>
914
914
# ...
915
915
# <%= person_form.fields_for :address do |address_fields| %>
916
916
# ...
@@ -951,7 +951,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
951
951
# the nested fields_for call will be repeated for each instance in the
952
952
# collection:
953
953
#
954
- # <%= form_for @person do |person_form| %>
954
+ # <%= form_with model: @person do |person_form| %>
955
955
# ...
956
956
# <%= person_form.fields_for :projects do |project_fields| %>
957
957
# <% if project_fields.object.active? %>
@@ -963,7 +963,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
963
963
#
964
964
# It's also possible to specify the instance to be used:
965
965
#
966
- # <%= form_for @person do |person_form| %>
966
+ # <%= form_with model: @person do |person_form| %>
967
967
# ...
968
968
# <% @person.projects.each do |project| %>
969
969
# <% if project.active? %>
@@ -977,7 +977,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
977
977
#
978
978
# Or a collection to be used:
979
979
#
980
- # <%= form_for @person do |person_form| %>
980
+ # <%= form_with model: @person do |person_form| %>
981
981
# ...
982
982
# <%= person_form.fields_for :projects, @active_projects do |project_fields| %>
983
983
# Name: <%= project_fields.text_field :name %>
@@ -999,7 +999,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
999
999
# parameter with a value that evaluates to +true+
1000
1000
# (e.g. 1, '1', true, or 'true'):
1001
1001
#
1002
- # <%= form_for @person do |person_form| %>
1002
+ # <%= form_with model: @person do |person_form| %>
1003
1003
# ...
1004
1004
# <%= person_form.fields_for :projects do |project_fields| %>
1005
1005
# Delete: <%= project_fields.check_box :_destroy %>
@@ -1011,7 +1011,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
1011
1011
# object in the array. For this purpose, the <tt>index</tt> method is
1012
1012
# available in the FormBuilder object.
1013
1013
#
1014
- # <%= form_for @person do |person_form| %>
1014
+ # <%= form_with model: @person do |person_form| %>
1015
1015
# ...
1016
1016
# <%= person_form.fields_for :projects do |project_fields| %>
1017
1017
# Project #<%= project_fields.index %>
@@ -1220,7 +1220,7 @@ def hidden_field(object_name, method, options = {})
1220
1220
# hash with +options+. These options will be tagged onto the HTML as an HTML element attribute as in the example
1221
1221
# shown.
1222
1222
#
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>.
1224
1224
#
1225
1225
# ==== Options
1226
1226
# * Creates standard HTML attributes for the tag.
@@ -1629,10 +1629,10 @@ def default_form_builder_class
1629
1629
#
1630
1630
# A +FormBuilder+ object is associated with a particular model object and
1631
1631
# 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+.
1633
1633
# For example:
1634
1634
#
1635
- # <%= form_for @person do |person_form| %>
1635
+ # <%= form_with model: @person do |person_form| %>
1636
1636
# Name: <%= person_form.text_field :name %>
1637
1637
# Admin: <%= person_form.check_box :admin %>
1638
1638
# <% end %>
@@ -1668,7 +1668,7 @@ def default_form_builder_class
1668
1668
#
1669
1669
# The +div_radio_button+ code from above can now be used as follows:
1670
1670
#
1671
- # <%= form_for @person, :builder => MyFormBuilder do |f| %>
1671
+ # <%= form_with model: @person, :builder => MyFormBuilder do |f| %>
1672
1672
# I am a child: <%= f.div_radio_button(:admin, "child") %>
1673
1673
# I am an adult: <%= f.div_radio_button(:admin, "adult") %>
1674
1674
# <% end -%>
@@ -1738,7 +1738,7 @@ def initialize(object_name, object, template, options)
1738
1738
#
1739
1739
# return the <tt><form></tt> element's <tt>id</tt> attribute.
1740
1740
#
1741
- # <%= form_for @article do |f| %>
1741
+ # <%= form_with model: @article do |f| %>
1742
1742
# <%# ... %>
1743
1743
#
1744
1744
# <% content_for :sticky_footer do %>
@@ -1760,7 +1760,7 @@ def id
1760
1760
# Return the value generated by the <tt>FormBuilder</tt> for the given
1761
1761
# attribute name.
1762
1762
#
1763
- # <%= form_for @article do |f| %>
1763
+ # <%= form_with model: @article do |f| %>
1764
1764
# <%= f.label :title %>
1765
1765
# <%= f.text_field :title, aria: { describedby: f.field_id(:title, :error) } %>
1766
1766
# <%= tag.span("is blank", id: f.field_id(:title, :error) %>
@@ -1781,12 +1781,12 @@ def field_id(method, *suffixes, namespace: @options[:namespace], index: @options
1781
1781
# Return the value generated by the <tt>FormBuilder</tt> for the given
1782
1782
# attribute name.
1783
1783
#
1784
- # <%= form_for @article do |f| %>
1784
+ # <%= form_with model: @article do |f| %>
1785
1785
# <%= f.text_field :title, name: f.field_name(:title, :subtitle) %>
1786
1786
# <%# => <input type="text" name="article[title][subtitle]"> %>
1787
1787
# <% end %>
1788
1788
#
1789
- # <%= form_for @article do |f| %>
1789
+ # <%= form_with model: @article do |f| %>
1790
1790
# <%= f.text_field :tag, name: f.field_name(:tag, multiple: true) %>
1791
1791
# <%# => <input type="text" name="article[tag][]"> %>
1792
1792
# <% end %>
@@ -2034,12 +2034,12 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2034
2034
end
2035
2035
end
2036
2036
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
2038
2038
# doesn't create the form tags themselves. This makes fields_for suitable
2039
2039
# for specifying additional model objects in the same form.
2040
2040
#
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
2043
2043
# a FormBuilder object associated with a particular model object to a block,
2044
2044
# and within the block allows methods to be called on the builder to
2045
2045
# generate fields associated with the model object. Fields may reflect
@@ -2050,7 +2050,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2050
2050
# both an object name (represented by either a symbol or string) and the
2051
2051
# object itself can be passed to the method separately -
2052
2052
#
2053
- # <%= form_for @person do |person_form| %>
2053
+ # <%= form_with model: @person do |person_form| %>
2054
2054
# First name: <%= person_form.text_field :first_name %>
2055
2055
# Last name : <%= person_form.text_field :last_name %>
2056
2056
#
@@ -2099,7 +2099,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2099
2099
# name and value parameters are provided and the provided value has the shape of an
2100
2100
# option Hash. To remove the ambiguity, explicitly pass an option Hash, even if empty.
2101
2101
#
2102
- # <%= form_for @person do |person_form| %>
2102
+ # <%= form_with model: @person do |person_form| %>
2103
2103
# ...
2104
2104
# <%= fields_for :permission, @person.permission, {} do |permission_fields| %>
2105
2105
# 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 = {})
2143
2143
#
2144
2144
# This model can now be used with a nested fields_for, like so:
2145
2145
#
2146
- # <%= form_for @person do |person_form| %>
2146
+ # <%= form_with model: @person do |person_form| %>
2147
2147
# ...
2148
2148
# <%= person_form.fields_for :address do |address_fields| %>
2149
2149
# Street : <%= address_fields.text_field :street %>
@@ -2173,7 +2173,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2173
2173
# with a value that evaluates to +true+, you will destroy the associated
2174
2174
# model (e.g. 1, '1', true, or 'true'):
2175
2175
#
2176
- # <%= form_for @person do |person_form| %>
2176
+ # <%= form_with model: @person do |person_form| %>
2177
2177
# ...
2178
2178
# <%= person_form.fields_for :address do |address_fields| %>
2179
2179
# ...
@@ -2214,7 +2214,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2214
2214
# the nested fields_for call will be repeated for each instance in the
2215
2215
# collection:
2216
2216
#
2217
- # <%= form_for @person do |person_form| %>
2217
+ # <%= form_with model: @person do |person_form| %>
2218
2218
# ...
2219
2219
# <%= person_form.fields_for :projects do |project_fields| %>
2220
2220
# <% if project_fields.object.active? %>
@@ -2226,7 +2226,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2226
2226
#
2227
2227
# It's also possible to specify the instance to be used:
2228
2228
#
2229
- # <%= form_for @person do |person_form| %>
2229
+ # <%= form_with model: @person do |person_form| %>
2230
2230
# ...
2231
2231
# <% @person.projects.each do |project| %>
2232
2232
# <% if project.active? %>
@@ -2240,7 +2240,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2240
2240
#
2241
2241
# Or a collection to be used:
2242
2242
#
2243
- # <%= form_for @person do |person_form| %>
2243
+ # <%= form_with model: @person do |person_form| %>
2244
2244
# ...
2245
2245
# <%= person_form.fields_for :projects, @active_projects do |project_fields| %>
2246
2246
# Name: <%= project_fields.text_field :name %>
@@ -2262,7 +2262,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2262
2262
# parameter with a value that evaluates to +true+
2263
2263
# (e.g. 1, '1', true, or 'true'):
2264
2264
#
2265
- # <%= form_for @person do |person_form| %>
2265
+ # <%= form_with model: @person do |person_form| %>
2266
2266
# ...
2267
2267
# <%= person_form.fields_for :projects do |project_fields| %>
2268
2268
# Delete: <%= project_fields.check_box :_destroy %>
@@ -2274,7 +2274,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2274
2274
# object in the array. For this purpose, the <tt>index</tt> method
2275
2275
# is available in the FormBuilder object.
2276
2276
#
2277
- # <%= form_for @person do |person_form| %>
2277
+ # <%= form_with model: @person do |person_form| %>
2278
2278
# ...
2279
2279
# <%= person_form.fields_for :projects do |project_fields| %>
2280
2280
# Project #<%= project_fields.index %>
@@ -2562,7 +2562,7 @@ def file_field(method, options = {})
2562
2562
# Add the submit button for the given form. When no value is given, it checks
2563
2563
# if the object is a new resource or not to create the proper label:
2564
2564
#
2565
- # <%= form_for @article do |f| %>
2565
+ # <%= form_with model: @article do |f| %>
2566
2566
# <%= f.submit %>
2567
2567
# <% end %>
2568
2568
#
@@ -2595,7 +2595,7 @@ def submit(value = nil, options = {})
2595
2595
# Add the submit button for the given form. When no value is given, it checks
2596
2596
# if the object is a new resource or not to create the proper label:
2597
2597
#
2598
- # <%= form_for @article do |f| %>
2598
+ # <%= form_with model: @article do |f| %>
2599
2599
# <%= f.button %>
2600
2600
# <% end %>
2601
2601
# In the example above, if <tt>@article</tt> is a new record, it will use "Create Article" as
0 commit comments