actionview 7.2.1.1 → 8.0.0.rc1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -30,20 +30,21 @@ module ActionView
30
30
  # when the form is initially displayed, input fields corresponding to attributes
31
31
  # of the resource should show the current values of those attributes.
32
32
  #
33
- # In \Rails, this is usually achieved by creating the form using +form_for+ and
34
- # a number of related helper methods. +form_for+ generates an appropriate <tt>form</tt>
35
- # tag and yields a form builder object that knows the model the form is about.
36
- # Input fields are created by calling methods defined on the form builder, which
37
- # means they are able to generate the appropriate names and default values
33
+ # In \Rails, this is usually achieved by creating the form using either
34
+ # +form_with+ or +form_for+ and a number of related helper methods. These
35
+ # methods generate an appropriate <tt>form</tt> tag and yield a form
36
+ # builder object that knows the model the form is about. Input fields are
37
+ # created by calling methods defined on the form builder, which means they
38
+ # are able to generate the appropriate names and default values
38
39
  # corresponding to the model attributes, as well as convenient IDs, etc.
39
- # Conventions in the generated field names allow controllers to receive form data
40
- # nicely structured in +params+ with no effort on your side.
40
+ # Conventions in the generated field names allow controllers to receive form
41
+ # data nicely structured in +params+ with no effort on your side.
41
42
  #
42
43
  # For example, to create a new person you typically set up a new instance of
43
44
  # +Person+ in the <tt>PeopleController#new</tt> action, <tt>@person</tt>, and
44
- # in the view template pass that object to +form_for+:
45
+ # in the view template pass that object to +form_with+ or +form_for+:
45
46
  #
46
- # <%= form_for @person do |f| %>
47
+ # <%= form_with model: @person do |f| %>
47
48
  # <%= f.label :first_name %>:
48
49
  # <%= f.text_field :first_name %><br />
49
50
  #
@@ -132,8 +133,8 @@ module ActionView
132
133
  # <%= form_for :person do |f| %>
133
134
  # First name: <%= f.text_field :first_name %><br />
134
135
  # Last name : <%= f.text_field :last_name %><br />
135
- # Biography : <%= f.text_area :biography %><br />
136
- # Admin? : <%= f.check_box :admin %><br />
136
+ # Biography : <%= f.textarea :biography %><br />
137
+ # Admin? : <%= f.checkbox :admin %><br />
137
138
  # <%= f.submit %>
138
139
  # <% end %>
139
140
  #
@@ -199,8 +200,8 @@ module ActionView
199
200
  # <%= form_for :person do |f| %>
200
201
  # First name: <%= f.text_field :first_name %>
201
202
  # Last name : <%= f.text_field :last_name %>
202
- # Biography : <%= text_area :person, :biography %>
203
- # Admin? : <%= check_box_tag "person[admin]", "1", @person.company.admin? %>
203
+ # Biography : <%= textarea :person, :biography %>
204
+ # Admin? : <%= checkbox_tag "person[admin]", "1", @person.company.admin? %>
204
205
  # <%= f.submit %>
205
206
  # <% end %>
206
207
  #
@@ -389,8 +390,8 @@ module ActionView
389
390
  # <%= form_for @person, url: { action: "create" }, builder: LabellingFormBuilder do |f| %>
390
391
  # <%= f.text_field :first_name %>
391
392
  # <%= f.text_field :last_name %>
392
- # <%= f.text_area :biography %>
393
- # <%= f.check_box :admin %>
393
+ # <%= f.textarea :biography %>
394
+ # <%= f.checkbox :admin %>
394
395
  # <%= f.submit %>
395
396
  # <% end %>
396
397
  #
@@ -668,8 +669,8 @@ module ActionView
668
669
  # <%= form.text_field :first_name %>
669
670
  # <%= form.text_field :last_name %>
670
671
  #
671
- # <%= text_area :person, :biography %>
672
- # <%= check_box_tag "person[admin]", "1", @person.company.admin? %>
672
+ # <%= textarea :person, :biography %>
673
+ # <%= checkbox_tag "person[admin]", "1", @person.company.admin? %>
673
674
  #
674
675
  # <%= form.submit %>
675
676
  # <% end %>
@@ -730,8 +731,8 @@ module ActionView
730
731
  # <%= form_with model: @person, url: { action: "create" }, builder: LabellingFormBuilder do |form| %>
731
732
  # <%= form.text_field :first_name %>
732
733
  # <%= form.text_field :last_name %>
733
- # <%= form.text_area :biography %>
734
- # <%= form.check_box :admin %>
734
+ # <%= form.textarea :biography %>
735
+ # <%= form.checkbox :admin %>
735
736
  # <%= form.submit %>
736
737
  # <% end %>
737
738
  #
@@ -753,7 +754,7 @@ module ActionView
753
754
  # form_with(**options.merge(builder: LabellingFormBuilder), &block)
754
755
  # end
755
756
  def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block)
756
- ActionView.deprecator.warn("Passing nil to the :model argument is deprecated and will raise in Rails 8.0") if model.nil?
757
+ raise ArgumentError, "Passed nil to the :model argument, expect an object or false" if model.nil?
757
758
 
758
759
  options = { allow_method_names_outside_object: true, skip_default_ids: !form_with_generates_ids }.merge!(options)
759
760
 
@@ -783,9 +784,9 @@ module ActionView
783
784
  end
784
785
  end
785
786
 
786
- # Creates a scope around a specific model object like form_with, but
787
- # doesn't create the form tags themselves. This makes fields_for suitable
788
- # for specifying additional model objects in the same form.
787
+ # Creates a scope around a specific model object like +form_with+, but
788
+ # doesn't create the form tags themselves. This makes +fields_for+
789
+ # suitable for specifying additional model objects in the same form.
789
790
  #
790
791
  # Although the usage and purpose of +fields_for+ is similar to +form_with+'s,
791
792
  # its method signature is slightly different. Like +form_with+, it yields
@@ -804,7 +805,7 @@ module ActionView
804
805
  # Last name : <%= person_form.text_field :last_name %>
805
806
  #
806
807
  # <%= fields_for :permission, @person.permission do |permission_fields| %>
807
- # Admin? : <%= permission_fields.check_box :admin %>
808
+ # Admin? : <%= permission_fields.checkbox :admin %>
808
809
  # <% end %>
809
810
  #
810
811
  # <%= person_form.submit %>
@@ -821,7 +822,7 @@ module ActionView
821
822
  # object to +fields_for+ -
822
823
  #
823
824
  # <%= fields_for :permission do |permission_fields| %>
824
- # Admin?: <%= permission_fields.check_box :admin %>
825
+ # Admin?: <%= permission_fields.checkbox :admin %>
825
826
  # <% end %>
826
827
  #
827
828
  # ...in which case, if <tt>:permission</tt> also happens to be the name of an
@@ -833,7 +834,7 @@ module ActionView
833
834
  # name has been omitted) -
834
835
  #
835
836
  # <%= fields_for @person.permission do |permission_fields| %>
836
- # Admin?: <%= permission_fields.check_box :admin %>
837
+ # Admin?: <%= permission_fields.checkbox :admin %>
837
838
  # <% end %>
838
839
  #
839
840
  # and +fields_for+ will derive the required name of the field from the
@@ -914,7 +915,7 @@ module ActionView
914
915
  # ...
915
916
  # <%= person_form.fields_for :address do |address_fields| %>
916
917
  # ...
917
- # Delete: <%= address_fields.check_box :_destroy %>
918
+ # Delete: <%= address_fields.checkbox :_destroy %>
918
919
  # <% end %>
919
920
  # ...
920
921
  # <% end %>
@@ -1002,7 +1003,7 @@ module ActionView
1002
1003
  # <%= form_with model: @person do |person_form| %>
1003
1004
  # ...
1004
1005
  # <%= person_form.fields_for :projects do |project_fields| %>
1005
- # Delete: <%= project_fields.check_box :_destroy %>
1006
+ # Delete: <%= project_fields.checkbox :_destroy %>
1006
1007
  # <% end %>
1007
1008
  # ...
1008
1009
  # <% end %>
@@ -1069,8 +1070,8 @@ module ActionView
1069
1070
  # <%= fields model: @comment do |fields| %>
1070
1071
  # <%= fields.text_field :body %>
1071
1072
  #
1072
- # <%= text_area :commenter, :biography %>
1073
- # <%= check_box_tag "comment[all_caps]", "1", @comment.commenter.hulk_mode? %>
1073
+ # <%= textarea :commenter, :biography %>
1074
+ # <%= checkbox_tag "comment[all_caps]", "1", @comment.commenter.hulk_mode? %>
1074
1075
  # <% end %>
1075
1076
  #
1076
1077
  # Same goes for the methods in FormOptionsHelper and DateHelper designed
@@ -1255,28 +1256,29 @@ module ActionView
1255
1256
  # hash with +options+.
1256
1257
  #
1257
1258
  # ==== Examples
1258
- # text_area(:article, :body, cols: 20, rows: 40)
1259
+ # textarea(:article, :body, cols: 20, rows: 40)
1259
1260
  # # => <textarea cols="20" rows="40" id="article_body" name="article[body]">
1260
1261
  # # #{@article.body}
1261
1262
  # # </textarea>
1262
1263
  #
1263
- # text_area(:comment, :text, size: "20x30")
1264
+ # textarea(:comment, :text, size: "20x30")
1264
1265
  # # => <textarea cols="20" rows="30" id="comment_text" name="comment[text]">
1265
1266
  # # #{@comment.text}
1266
1267
  # # </textarea>
1267
1268
  #
1268
- # text_area(:application, :notes, cols: 40, rows: 15, class: 'app_input')
1269
+ # textarea(:application, :notes, cols: 40, rows: 15, class: 'app_input')
1269
1270
  # # => <textarea cols="40" rows="15" id="application_notes" name="application[notes]" class="app_input">
1270
1271
  # # #{@application.notes}
1271
1272
  # # </textarea>
1272
1273
  #
1273
- # text_area(:entry, :body, size: "20x20", disabled: 'disabled')
1274
+ # textarea(:entry, :body, size: "20x20", disabled: 'disabled')
1274
1275
  # # => <textarea cols="20" rows="20" id="entry_body" name="entry[body]" disabled="disabled">
1275
1276
  # # #{@entry.body}
1276
1277
  # # </textarea>
1277
- def text_area(object_name, method, options = {})
1278
+ def textarea(object_name, method, options = {})
1278
1279
  Tags::TextArea.new(object_name, method, self, options).render
1279
1280
  end
1281
+ alias_method :text_area, :textarea
1280
1282
 
1281
1283
  # Returns a checkbox tag tailored for accessing a specified attribute (identified by +method+) on an object
1282
1284
  # assigned to the template (identified by +object+). This object must be an instance object (@object) and not a local object.
@@ -1316,7 +1318,7 @@ module ActionView
1316
1318
  # within an array-like parameter, as in
1317
1319
  #
1318
1320
  # <%= fields_for "project[invoice_attributes][]", invoice, index: nil do |form| %>
1319
- # <%= form.check_box :paid %>
1321
+ # <%= form.checkbox :paid %>
1320
1322
  # ...
1321
1323
  # <% end %>
1322
1324
  #
@@ -1324,27 +1326,28 @@ module ActionView
1324
1326
  # the elements of the array. For each item with a checked check box you
1325
1327
  # get an extra ghost item with only that attribute, assigned to "0".
1326
1328
  #
1327
- # In that case it is preferable to either use +check_box_tag+ or to use
1329
+ # In that case it is preferable to either use +checkbox_tag+ or to use
1328
1330
  # hashes instead of arrays.
1329
1331
  #
1330
1332
  # ==== Examples
1331
1333
  #
1332
1334
  # # Let's say that @article.validated? is 1:
1333
- # check_box("article", "validated")
1335
+ # checkbox("article", "validated")
1334
1336
  # # => <input name="article[validated]" type="hidden" value="0" />
1335
1337
  # # <input checked="checked" type="checkbox" id="article_validated" name="article[validated]" value="1" />
1336
1338
  #
1337
1339
  # # Let's say that @puppy.gooddog is "no":
1338
- # check_box("puppy", "gooddog", {}, "yes", "no")
1340
+ # checkbox("puppy", "gooddog", {}, "yes", "no")
1339
1341
  # # => <input name="puppy[gooddog]" type="hidden" value="no" />
1340
1342
  # # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
1341
1343
  #
1342
- # check_box("eula", "accepted", { class: 'eula_check' }, "yes", "no")
1344
+ # checkbox("eula", "accepted", { class: 'eula_check' }, "yes", "no")
1343
1345
  # # => <input name="eula[accepted]" type="hidden" value="no" />
1344
1346
  # # <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
1345
- def check_box(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
1347
+ def checkbox(object_name, method, options = {}, checked_value = "1", unchecked_value = "0")
1346
1348
  Tags::CheckBox.new(object_name, method, self, checked_value, unchecked_value, options).render
1347
1349
  end
1350
+ alias_method :check_box, :checkbox
1348
1351
 
1349
1352
  # Returns a radio button tag for accessing a specified attribute (identified by +method+) on an object
1350
1353
  # assigned to the template (identified by +object+). If the current value of +method+ is +tag_value+ the
@@ -1634,12 +1637,12 @@ module ActionView
1634
1637
  #
1635
1638
  # <%= form_with model: @person do |person_form| %>
1636
1639
  # Name: <%= person_form.text_field :name %>
1637
- # Admin: <%= person_form.check_box :admin %>
1640
+ # Admin: <%= person_form.checkbox :admin %>
1638
1641
  # <% end %>
1639
1642
  #
1640
1643
  # In the above block, a +FormBuilder+ object is yielded as the
1641
1644
  # +person_form+ variable. This allows you to generate the +text_field+
1642
- # and +check_box+ fields by specifying their eponymous methods, which
1645
+ # and +checkbox+ fields by specifying their eponymous methods, which
1643
1646
  # modify the underlying template and associates the <tt>@person</tt> model object
1644
1647
  # with the form.
1645
1648
  #
@@ -1681,7 +1684,7 @@ module ActionView
1681
1684
  # The methods which wrap a form helper call.
1682
1685
  class_attribute :field_helpers, default: [
1683
1686
  :fields_for, :fields, :label, :text_field, :password_field,
1684
- :hidden_field, :file_field, :text_area, :check_box,
1687
+ :hidden_field, :file_field, :textarea, :checkbox,
1685
1688
  :radio_button, :color_field, :search_field,
1686
1689
  :telephone_field, :phone_field, :date_field,
1687
1690
  :time_field, :datetime_field, :datetime_local_field,
@@ -1824,14 +1827,14 @@ module ActionView
1824
1827
  # Please refer to the documentation of the base helper for details.
1825
1828
 
1826
1829
  ##
1827
- # :method: text_area
1830
+ # :method: textarea
1828
1831
  #
1829
- # :call-seq: text_area(method, options = {})
1832
+ # :call-seq: textarea(method, options = {})
1830
1833
  #
1831
- # Wraps ActionView::Helpers::FormHelper#text_area for form builders:
1834
+ # Wraps ActionView::Helpers::FormHelper#textarea for form builders:
1832
1835
  #
1833
1836
  # <%= form_with model: @user do |f| %>
1834
- # <%= f.text_area :detail %>
1837
+ # <%= f.textarea :detail %>
1835
1838
  # <% end %>
1836
1839
  #
1837
1840
  # Please refer to the documentation of the base helper for details.
@@ -2019,24 +2022,20 @@ module ActionView
2019
2022
  # Please refer to the documentation of the base helper for details.
2020
2023
 
2021
2024
  ActiveSupport::CodeGenerator.batch(self, __FILE__, __LINE__) do |code_generator|
2022
- (field_helpers - [:label, :check_box, :radio_button, :fields_for, :fields, :hidden_field, :file_field]).each do |selector|
2023
- code_generator.define_cached_method(selector, namespace: :form_builder) do |batch|
2024
- batch.push <<-RUBY_EVAL
2025
- def #{selector}(method, options = {}) # def text_field(method, options = {})
2026
- @template.public_send( # @template.public_send(
2027
- #{selector.inspect}, # :text_field,
2028
- @object_name, # @object_name,
2029
- method, # method,
2030
- objectify_options(options)) # objectify_options(options))
2031
- end # end
2032
- RUBY_EVAL
2025
+ (field_helpers - [:label, :checkbox, :radio_button, :fields_for, :fields, :hidden_field, :file_field]).each do |selector|
2026
+ code_generator.class_eval do |batch|
2027
+ batch <<
2028
+ "def #{selector}(method, options = {})" <<
2029
+ " @template.#{selector}(@object_name, method, objectify_options(options))" <<
2030
+ "end"
2031
+ end
2033
2032
  end
2034
- end
2035
2033
  end
2034
+ alias_method :text_area, :textarea
2036
2035
 
2037
- # Creates a scope around a specific model object like form_with, but
2038
- # doesn't create the form tags themselves. This makes fields_for suitable
2039
- # for specifying additional model objects in the same form.
2036
+ # Creates a scope around a specific model object like +form_with+, but
2037
+ # doesn't create the form tags themselves. This makes +fields_for+
2038
+ # suitable for specifying additional model objects in the same form.
2040
2039
  #
2041
2040
  # Although the usage and purpose of +fields_for+ is similar to +form_with+'s,
2042
2041
  # its method signature is slightly different. Like +form_with+, it yields
@@ -2055,7 +2054,7 @@ module ActionView
2055
2054
  # Last name : <%= person_form.text_field :last_name %>
2056
2055
  #
2057
2056
  # <%= fields_for :permission, @person.permission do |permission_fields| %>
2058
- # Admin? : <%= permission_fields.check_box :admin %>
2057
+ # Admin? : <%= permission_fields.checkbox :admin %>
2059
2058
  # <% end %>
2060
2059
  #
2061
2060
  # <%= person_form.submit %>
@@ -2072,7 +2071,7 @@ module ActionView
2072
2071
  # object to +fields_for+ -
2073
2072
  #
2074
2073
  # <%= fields_for :permission do |permission_fields| %>
2075
- # Admin?: <%= permission_fields.check_box :admin %>
2074
+ # Admin?: <%= permission_fields.checkbox :admin %>
2076
2075
  # <% end %>
2077
2076
  #
2078
2077
  # ...in which case, if <tt>:permission</tt> also happens to be the name of an
@@ -2084,7 +2083,7 @@ module ActionView
2084
2083
  # name has been omitted) -
2085
2084
  #
2086
2085
  # <%= fields_for @person.permission do |permission_fields| %>
2087
- # Admin?: <%= permission_fields.check_box :admin %>
2086
+ # Admin?: <%= permission_fields.checkbox :admin %>
2088
2087
  # <% end %>
2089
2088
  #
2090
2089
  # and +fields_for+ will derive the required name of the field from the
@@ -2102,7 +2101,7 @@ module ActionView
2102
2101
  # <%= form_with model: @person do |person_form| %>
2103
2102
  # ...
2104
2103
  # <%= fields_for :permission, @person.permission, {} do |permission_fields| %>
2105
- # Admin?: <%= check_box_tag permission_fields.field_name(:admin), @person.permission[:admin] %>
2104
+ # Admin?: <%= checkbox_tag permission_fields.field_name(:admin), @person.permission[:admin] %>
2106
2105
  # <% end %>
2107
2106
  # ...
2108
2107
  # <% end %>
@@ -2177,7 +2176,7 @@ module ActionView
2177
2176
  # ...
2178
2177
  # <%= person_form.fields_for :address do |address_fields| %>
2179
2178
  # ...
2180
- # Delete: <%= address_fields.check_box :_destroy %>
2179
+ # Delete: <%= address_fields.checkbox :_destroy %>
2181
2180
  # <% end %>
2182
2181
  # ...
2183
2182
  # <% end %>
@@ -2265,7 +2264,7 @@ module ActionView
2265
2264
  # <%= form_with model: @person do |person_form| %>
2266
2265
  # ...
2267
2266
  # <%= person_form.fields_for :projects do |project_fields| %>
2268
- # Delete: <%= project_fields.check_box :_destroy %>
2267
+ # Delete: <%= project_fields.checkbox :_destroy %>
2269
2268
  # <% end %>
2270
2269
  # ...
2271
2270
  # <% end %>
@@ -2444,7 +2443,7 @@ module ActionView
2444
2443
  # within an array-like parameter, as in
2445
2444
  #
2446
2445
  # <%= fields_for "project[invoice_attributes][]", invoice, index: nil do |form| %>
2447
- # <%= form.check_box :paid %>
2446
+ # <%= form.checkbox :paid %>
2448
2447
  # ...
2449
2448
  # <% end %>
2450
2449
  #
@@ -2452,28 +2451,29 @@ module ActionView
2452
2451
  # the elements of the array. For each item with a checked check box you
2453
2452
  # get an extra ghost item with only that attribute, assigned to "0".
2454
2453
  #
2455
- # In that case it is preferable to either use +check_box_tag+ or to use
2454
+ # In that case it is preferable to either use +checkbox_tag+ or to use
2456
2455
  # hashes instead of arrays.
2457
2456
  #
2458
2457
  # ==== Examples
2459
2458
  #
2460
2459
  # # Let's say that @article.validated? is 1:
2461
- # check_box("validated")
2460
+ # checkbox("validated")
2462
2461
  # # => <input name="article[validated]" type="hidden" value="0" />
2463
2462
  # # <input checked="checked" type="checkbox" id="article_validated" name="article[validated]" value="1" />
2464
2463
  #
2465
2464
  # # Let's say that @puppy.gooddog is "no":
2466
- # check_box("gooddog", {}, "yes", "no")
2465
+ # checkbox("gooddog", {}, "yes", "no")
2467
2466
  # # => <input name="puppy[gooddog]" type="hidden" value="no" />
2468
2467
  # # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
2469
2468
  #
2470
2469
  # # Let's say that @eula.accepted is "no":
2471
- # check_box("accepted", { class: 'eula_check' }, "yes", "no")
2470
+ # checkbox("accepted", { class: 'eula_check' }, "yes", "no")
2472
2471
  # # => <input name="eula[accepted]" type="hidden" value="no" />
2473
2472
  # # <input type="checkbox" class="eula_check" id="eula_accepted" name="eula[accepted]" value="yes" />
2474
- def check_box(method, options = {}, checked_value = "1", unchecked_value = "0")
2475
- @template.check_box(@object_name, method, objectify_options(options), checked_value, unchecked_value)
2473
+ def checkbox(method, options = {}, checked_value = "1", unchecked_value = "0")
2474
+ @template.checkbox(@object_name, method, objectify_options(options), checked_value, unchecked_value)
2476
2475
  end
2476
+ alias_method :check_box, :checkbox
2477
2477
 
2478
2478
  # Returns a radio button tag for accessing a specified attribute (identified by +method+) on an object
2479
2479
  # assigned to the template (identified by +object+). If the current value of +method+ is +tag_value+ the
@@ -686,7 +686,7 @@ module ActionView
686
686
  # if a +User+ model has a +category_id+ field and in the form no category is selected, no +category_id+ parameter is sent. So,
687
687
  # any strong parameters idiom like:
688
688
  #
689
- # params.require(:user).permit(...)
689
+ # params.expect(user: [...])
690
690
  #
691
691
  # will raise an error since no <tt>{user: ...}</tt> will be present.
692
692
  #
@@ -723,7 +723,7 @@ module ActionView
723
723
  # end
724
724
  #
725
725
  # Sample usage (selecting the associated Author for an instance of Post, <tt>@post</tt>):
726
- # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial)
726
+ # collection_checkboxes(:post, :author_ids, Author.all, :id, :name_with_initial)
727
727
  #
728
728
  # If <tt>@post.author_ids</tt> is already <tt>[1]</tt>, this would return:
729
729
  # <input id="post_author_ids_1" name="post[author_ids][]" type="checkbox" value="1" checked="checked" />
@@ -736,8 +736,8 @@ module ActionView
736
736
  #
737
737
  # It is also possible to customize the way the elements will be shown by
738
738
  # giving a block to the method:
739
- # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
740
- # b.label { b.check_box }
739
+ # collection_checkboxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
740
+ # b.label { b.checkbox }
741
741
  # end
742
742
  #
743
743
  # The argument passed to the block is a special kind of builder for this
@@ -746,17 +746,17 @@ module ActionView
746
746
  # Using it, you can change the label and check box display order or even
747
747
  # use the label as wrapper, as in the example above.
748
748
  #
749
- # The builder methods <tt>label</tt> and <tt>check_box</tt> also accept
749
+ # The builder methods <tt>label</tt> and <tt>checkbox</tt> also accept
750
750
  # extra HTML options:
751
- # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
752
- # b.label(class: "check_box") { b.check_box(class: "check_box") }
751
+ # collection_checkboxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
752
+ # b.label(class: "checkbox") { b.checkbox(class: "checkbox") }
753
753
  # end
754
754
  #
755
755
  # There are also three special methods available: <tt>object</tt>, <tt>text</tt> and
756
756
  # <tt>value</tt>, which are the current item being rendered, its text and value methods,
757
757
  # respectively. You can use them like this:
758
- # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
759
- # b.label(:"data-value" => b.value) { b.check_box + b.text }
758
+ # collection_checkboxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
759
+ # b.label(:"data-value" => b.value) { b.checkbox + b.text }
760
760
  # end
761
761
  #
762
762
  # ==== Gotcha
@@ -779,9 +779,10 @@ module ActionView
779
779
  #
780
780
  # In the rare case you don't want this hidden field, you can pass the
781
781
  # <tt>include_hidden: false</tt> option to the helper method.
782
- def collection_check_boxes(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
782
+ def collection_checkboxes(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
783
783
  Tags::CollectionCheckBoxes.new(object, method, self, collection, value_method, text_method, options, html_options).render(&block)
784
784
  end
785
+ alias_method :collection_check_boxes, :collection_checkboxes
785
786
 
786
787
  private
787
788
  def option_html_attributes(element)
@@ -839,7 +840,7 @@ module ActionView
839
840
  class FormBuilder
840
841
  # Wraps ActionView::Helpers::FormOptionsHelper#select for form builders:
841
842
  #
842
- # <%= form_for @post do |f| %>
843
+ # <%= form_with model: @post do |f| %>
843
844
  # <%= f.select :person_id, Person.all.collect { |p| [ p.name, p.id ] }, include_blank: true %>
844
845
  # <%= f.submit %>
845
846
  # <% end %>
@@ -851,7 +852,7 @@ module ActionView
851
852
 
852
853
  # Wraps ActionView::Helpers::FormOptionsHelper#collection_select for form builders:
853
854
  #
854
- # <%= form_for @post do |f| %>
855
+ # <%= form_with model: @post do |f| %>
855
856
  # <%= f.collection_select :person_id, Author.all, :id, :name_with_initial, prompt: true %>
856
857
  # <%= f.submit %>
857
858
  # <% end %>
@@ -863,7 +864,7 @@ module ActionView
863
864
 
864
865
  # Wraps ActionView::Helpers::FormOptionsHelper#grouped_collection_select for form builders:
865
866
  #
866
- # <%= form_for @city do |f| %>
867
+ # <%= form_with model: @city do |f| %>
867
868
  # <%= f.grouped_collection_select :country_id, @continents, :countries, :name, :id, :name %>
868
869
  # <%= f.submit %>
869
870
  # <% end %>
@@ -875,7 +876,7 @@ module ActionView
875
876
 
876
877
  # Wraps ActionView::Helpers::FormOptionsHelper#time_zone_select for form builders:
877
878
  #
878
- # <%= form_for @user do |f| %>
879
+ # <%= form_with model: @user do |f| %>
879
880
  # <%= f.time_zone_select :time_zone, nil, include_blank: true %>
880
881
  # <%= f.submit %>
881
882
  # <% end %>
@@ -887,7 +888,7 @@ module ActionView
887
888
 
888
889
  # Wraps ActionView::Helpers::FormOptionsHelper#weekday_select for form builders:
889
890
  #
890
- # <%= form_for @user do |f| %>
891
+ # <%= form_with model: @user do |f| %>
891
892
  # <%= f.weekday_select :weekday, include_blank: true %>
892
893
  # <%= f.submit %>
893
894
  # <% end %>
@@ -897,21 +898,22 @@ module ActionView
897
898
  @template.weekday_select(@object_name, method, objectify_options(options), @default_html_options.merge(html_options))
898
899
  end
899
900
 
900
- # Wraps ActionView::Helpers::FormOptionsHelper#collection_check_boxes for form builders:
901
+ # Wraps ActionView::Helpers::FormOptionsHelper#collection_checkboxes for form builders:
901
902
  #
902
- # <%= form_for @post do |f| %>
903
- # <%= f.collection_check_boxes :author_ids, Author.all, :id, :name_with_initial %>
903
+ # <%= form_with model: @post do |f| %>
904
+ # <%= f.collection_checkboxes :author_ids, Author.all, :id, :name_with_initial %>
904
905
  # <%= f.submit %>
905
906
  # <% end %>
906
907
  #
907
908
  # Please refer to the documentation of the base helper for details.
908
- def collection_check_boxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
909
- @template.collection_check_boxes(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_html_options.merge(html_options), &block)
909
+ def collection_checkboxes(method, collection, value_method, text_method, options = {}, html_options = {}, &block)
910
+ @template.collection_checkboxes(@object_name, method, collection, value_method, text_method, objectify_options(options), @default_html_options.merge(html_options), &block)
910
911
  end
912
+ alias_method :collection_check_boxes, :collection_checkboxes
911
913
 
912
914
  # Wraps ActionView::Helpers::FormOptionsHelper#collection_radio_buttons for form builders:
913
915
  #
914
- # <%= form_for @post do |f| %>
916
+ # <%= form_with model: @post do |f| %>
915
917
  # <%= f.collection_radio_buttons :author_id, Author.all, :id, :name_with_initial %>
916
918
  # <%= f.submit %>
917
919
  # <% end %>
@@ -393,24 +393,24 @@ module ActionView
393
393
  # * Any other key creates standard HTML attributes for the tag.
394
394
  #
395
395
  # ==== Examples
396
- # text_area_tag 'post'
396
+ # textarea_tag 'post'
397
397
  # # => <textarea id="post" name="post"></textarea>
398
398
  #
399
- # text_area_tag 'bio', @user.bio
399
+ # textarea_tag 'bio', @user.bio
400
400
  # # => <textarea id="bio" name="bio">This is my biography.</textarea>
401
401
  #
402
- # text_area_tag 'body', nil, rows: 10, cols: 25
402
+ # textarea_tag 'body', nil, rows: 10, cols: 25
403
403
  # # => <textarea cols="25" id="body" name="body" rows="10"></textarea>
404
404
  #
405
- # text_area_tag 'body', nil, size: "25x10"
405
+ # textarea_tag 'body', nil, size: "25x10"
406
406
  # # => <textarea name="body" id="body" cols="25" rows="10"></textarea>
407
407
  #
408
- # text_area_tag 'description', "Description goes here.", disabled: true
408
+ # textarea_tag 'description', "Description goes here.", disabled: true
409
409
  # # => <textarea disabled="disabled" id="description" name="description">Description goes here.</textarea>
410
410
  #
411
- # text_area_tag 'comment', nil, class: 'comment_input'
411
+ # textarea_tag 'comment', nil, class: 'comment_input'
412
412
  # # => <textarea class="comment_input" id="comment" name="comment"></textarea>
413
- def text_area_tag(name, content = nil, options = {})
413
+ def textarea_tag(name, content = nil, options = {})
414
414
  options = options.stringify_keys
415
415
 
416
416
  if size = options.delete("size")
@@ -422,12 +422,13 @@ module ActionView
422
422
 
423
423
  content_tag :textarea, content.to_s.html_safe, { "name" => name, "id" => sanitize_to_id(name) }.update(options)
424
424
  end
425
+ alias_method :text_area_tag, :textarea_tag
425
426
 
426
427
  ##
427
428
  # :call-seq:
428
- # check_box_tag(name, options = {})
429
- # check_box_tag(name, value, options = {})
430
- # check_box_tag(name, value, checked, options = {})
429
+ # checkbox_tag(name, options = {})
430
+ # checkbox_tag(name, value, options = {})
431
+ # checkbox_tag(name, value, checked, options = {})
431
432
  #
432
433
  # Creates a check box form input tag.
433
434
  #
@@ -438,21 +439,21 @@ module ActionView
438
439
  # * Any other key creates standard HTML options for the tag.
439
440
  #
440
441
  # ==== Examples
441
- # check_box_tag 'accept'
442
+ # checkbox_tag 'accept'
442
443
  # # => <input id="accept" name="accept" type="checkbox" value="1" />
443
444
  #
444
- # check_box_tag 'rock', 'rock music'
445
+ # checkbox_tag 'rock', 'rock music'
445
446
  # # => <input id="rock" name="rock" type="checkbox" value="rock music" />
446
447
  #
447
- # check_box_tag 'receive_email', 'yes', true
448
+ # checkbox_tag 'receive_email', 'yes', true
448
449
  # # => <input checked="checked" id="receive_email" name="receive_email" type="checkbox" value="yes" />
449
450
  #
450
- # check_box_tag 'tos', 'yes', false, class: 'accept_tos'
451
+ # checkbox_tag 'tos', 'yes', false, class: 'accept_tos'
451
452
  # # => <input class="accept_tos" id="tos" name="tos" type="checkbox" value="yes" />
452
453
  #
453
- # check_box_tag 'eula', 'accepted', false, disabled: true
454
+ # checkbox_tag 'eula', 'accepted', false, disabled: true
454
455
  # # => <input disabled="disabled" id="eula" name="eula" type="checkbox" value="accepted" />
455
- def check_box_tag(name, *args)
456
+ def checkbox_tag(name, *args)
456
457
  if args.length >= 4
457
458
  raise ArgumentError, "wrong number of arguments (given #{args.length + 1}, expected 1..4)"
458
459
  end
@@ -462,6 +463,7 @@ module ActionView
462
463
  html_options["checked"] = "checked" if checked
463
464
  tag :input, html_options
464
465
  end
466
+ alias_method :check_box_tag, :checkbox_tag
465
467
 
466
468
  ##
467
469
  # :call-seq: