@@ -133,7 +133,7 @@ module FormHelper
133
133
# First name: <%= f.text_field :first_name %><br />
134
134
# Last name : <%= f.text_field :last_name %><br />
135
135
# Biography : <%= f.text_area :biography %><br />
136
- # Admin? : <%= f.check_box :admin %><br />
136
+ # Admin? : <%= f.checkbox :admin %><br />
137
137
# <%= f.submit %>
138
138
# <% end %>
139
139
#
@@ -200,7 +200,7 @@ module FormHelper
200
200
# First name: <%= f.text_field :first_name %>
201
201
# Last name : <%= f.text_field :last_name %>
202
202
# Biography : <%= text_area :person, :biography %>
203
- # Admin? : <%= check_box_tag "person[admin]", "1", @person.company.admin? %>
203
+ # Admin? : <%= checkbox_tag "person[admin]", "1", @person.company.admin? %>
204
204
# <%= f.submit %>
205
205
# <% end %>
206
206
#
@@ -390,7 +390,7 @@ module FormHelper
390
390
# <%= f.text_field :first_name %>
391
391
# <%= f.text_field :last_name %>
392
392
# <%= f.text_area :biography %>
393
- # <%= f.check_box :admin %>
393
+ # <%= f.checkbox :admin %>
394
394
# <%= f.submit %>
395
395
# <% end %>
396
396
#
@@ -669,7 +669,7 @@ def apply_form_for_options!(object, options) # :nodoc:
669
669
# <%= form.text_field :last_name %>
670
670
#
671
671
# <%= text_area :person, :biography %>
672
- # <%= check_box_tag "person[admin]", "1", @person.company.admin? %>
672
+ # <%= checkbox_tag "person[admin]", "1", @person.company.admin? %>
673
673
#
674
674
# <%= form.submit %>
675
675
# <% end %>
@@ -731,7 +731,7 @@ def apply_form_for_options!(object, options) # :nodoc:
731
731
# <%= form.text_field :first_name %>
732
732
# <%= form.text_field :last_name %>
733
733
# <%= form.text_area :biography %>
734
- # <%= form.check_box :admin %>
734
+ # <%= form.checkbox :admin %>
735
735
# <%= form.submit %>
736
736
# <% end %>
737
737
#
@@ -804,7 +804,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
804
804
# Last name : <%= person_form.text_field :last_name %>
805
805
#
806
806
# <%= fields_for :permission, @person.permission do |permission_fields| %>
807
- # Admin? : <%= permission_fields.check_box :admin %>
807
+ # Admin? : <%= permission_fields.checkbox :admin %>
808
808
# <% end %>
809
809
#
810
810
# <%= person_form.submit %>
@@ -821,7 +821,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
821
821
# object to +fields_for+ -
822
822
#
823
823
# <%= fields_for :permission do |permission_fields| %>
824
- # Admin?: <%= permission_fields.check_box :admin %>
824
+ # Admin?: <%= permission_fields.checkbox :admin %>
825
825
# <% end %>
826
826
#
827
827
# ...in which case, if <tt>:permission</tt> also happens to be the name of an
@@ -833,7 +833,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
833
833
# name has been omitted) -
834
834
#
835
835
# <%= fields_for @person.permission do |permission_fields| %>
836
- # Admin?: <%= permission_fields.check_box :admin %>
836
+ # Admin?: <%= permission_fields.checkbox :admin %>
837
837
# <% end %>
838
838
#
839
839
# and +fields_for+ will derive the required name of the field from the
@@ -914,7 +914,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
914
914
# ...
915
915
# <%= person_form.fields_for :address do |address_fields| %>
916
916
# ...
917
- # Delete: <%= address_fields.check_box :_destroy %>
917
+ # Delete: <%= address_fields.checkbox :_destroy %>
918
918
# <% end %>
919
919
# ...
920
920
# <% end %>
@@ -1002,7 +1002,7 @@ def form_with(model: false, scope: nil, url: nil, format: nil, **options, &block
1002
1002
# <%= form_with model: @person do |person_form| %>
1003
1003
# ...
1004
1004
# <%= person_form.fields_for :projects do |project_fields| %>
1005
- # Delete: <%= project_fields.check_box :_destroy %>
1005
+ # Delete: <%= project_fields.checkbox :_destroy %>
1006
1006
# <% end %>
1007
1007
# ...
1008
1008
# <% end %>
@@ -1070,7 +1070,7 @@ def fields_for(record_name, record_object = nil, options = {}, &block)
1070
1070
# <%= fields.text_field :body %>
1071
1071
#
1072
1072
# <%= text_area :commenter, :biography %>
1073
- # <%= check_box_tag "comment[all_caps]", "1", @comment.commenter.hulk_mode? %>
1073
+ # <%= checkbox_tag "comment[all_caps]", "1", @comment.commenter.hulk_mode? %>
1074
1074
# <% end %>
1075
1075
#
1076
1076
# Same goes for the methods in FormOptionsHelper and DateHelper designed
@@ -1316,35 +1316,36 @@ def text_area(object_name, method, options = {})
1316
1316
# within an array-like parameter, as in
1317
1317
#
1318
1318
# <%= fields_for "project[invoice_attributes][]", invoice, index: nil do |form| %>
1319
- # <%= form.check_box :paid %>
1319
+ # <%= form.checkbox :paid %>
1320
1320
# ...
1321
1321
# <% end %>
1322
1322
#
1323
1323
# because parameter name repetition is precisely what \Rails seeks to distinguish
1324
1324
# the elements of the array. For each item with a checked check box you
1325
1325
# get an extra ghost item with only that attribute, assigned to "0".
1326
1326
#
1327
- # In that case it is preferable to either use +check_box_tag + or to use
1327
+ # In that case it is preferable to either use +checkbox_tag + or to use
1328
1328
# hashes instead of arrays.
1329
1329
#
1330
1330
# ==== Examples
1331
1331
#
1332
1332
# # Let's say that @article.validated? is 1:
1333
- # check_box ("article", "validated")
1333
+ # checkbox ("article", "validated")
1334
1334
# # => <input name="article[validated]" type="hidden" value="0" />
1335
1335
# # <input checked="checked" type="checkbox" id="article_validated" name="article[validated]" value="1" />
1336
1336
#
1337
1337
# # Let's say that @puppy.gooddog is "no":
1338
- # check_box ("puppy", "gooddog", {}, "yes", "no")
1338
+ # checkbox ("puppy", "gooddog", {}, "yes", "no")
1339
1339
# # => <input name="puppy[gooddog]" type="hidden" value="no" />
1340
1340
# # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
1341
1341
#
1342
- # check_box ("eula", "accepted", { class: 'eula_check' }, "yes", "no")
1342
+ # checkbox ("eula", "accepted", { class: 'eula_check' }, "yes", "no")
1343
1343
# # => <input name="eula[accepted]" type="hidden" value="no" />
1344
1344
# # <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" )
1345
+ def checkbox ( object_name , method , options = { } , checked_value = "1" , unchecked_value = "0" )
1346
1346
Tags ::CheckBox . new ( object_name , method , self , checked_value , unchecked_value , options ) . render
1347
1347
end
1348
+ alias_method :check_box , :checkbox
1348
1349
1349
1350
# Returns a radio button tag for accessing a specified attribute (identified by +method+) on an object
1350
1351
# assigned to the template (identified by +object+). If the current value of +method+ is +tag_value+ the
@@ -1634,12 +1635,12 @@ def default_form_builder_class
1634
1635
#
1635
1636
# <%= form_with model: @person do |person_form| %>
1636
1637
# Name: <%= person_form.text_field :name %>
1637
- # Admin: <%= person_form.check_box :admin %>
1638
+ # Admin: <%= person_form.checkbox :admin %>
1638
1639
# <% end %>
1639
1640
#
1640
1641
# In the above block, a +FormBuilder+ object is yielded as the
1641
1642
# +person_form+ variable. This allows you to generate the +text_field+
1642
- # and +check_box + fields by specifying their eponymous methods, which
1643
+ # and +checkbox + fields by specifying their eponymous methods, which
1643
1644
# modify the underlying template and associates the <tt>@person</tt> model object
1644
1645
# with the form.
1645
1646
#
@@ -1681,7 +1682,7 @@ class FormBuilder
1681
1682
# The methods which wrap a form helper call.
1682
1683
class_attribute :field_helpers , default : [
1683
1684
:fields_for , :fields , :label , :text_field , :password_field ,
1684
- :hidden_field , :file_field , :text_area , :check_box ,
1685
+ :hidden_field , :file_field , :text_area , :checkbox ,
1685
1686
:radio_button , :color_field , :search_field ,
1686
1687
:telephone_field , :phone_field , :date_field ,
1687
1688
:time_field , :datetime_field , :datetime_local_field ,
@@ -2019,7 +2020,7 @@ def field_name(method, *methods, multiple: false, index: @options[:index])
2019
2020
# Please refer to the documentation of the base helper for details.
2020
2021
2021
2022
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
+ ( field_helpers - [ :label , :checkbox , :radio_button , :fields_for , :fields , :hidden_field , :file_field ] ) . each do |selector |
2023
2024
code_generator . define_cached_method ( selector , namespace : :form_builder ) do |batch |
2024
2025
batch . push <<-RUBY_EVAL
2025
2026
def #{ selector } (method, options = {}) # def text_field(method, options = {})
@@ -2055,7 +2056,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2055
2056
# Last name : <%= person_form.text_field :last_name %>
2056
2057
#
2057
2058
# <%= fields_for :permission, @person.permission do |permission_fields| %>
2058
- # Admin? : <%= permission_fields.check_box :admin %>
2059
+ # Admin? : <%= permission_fields.checkbox :admin %>
2059
2060
# <% end %>
2060
2061
#
2061
2062
# <%= person_form.submit %>
@@ -2072,7 +2073,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2072
2073
# object to +fields_for+ -
2073
2074
#
2074
2075
# <%= fields_for :permission do |permission_fields| %>
2075
- # Admin?: <%= permission_fields.check_box :admin %>
2076
+ # Admin?: <%= permission_fields.checkbox :admin %>
2076
2077
# <% end %>
2077
2078
#
2078
2079
# ...in which case, if <tt>:permission</tt> also happens to be the name of an
@@ -2084,7 +2085,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2084
2085
# name has been omitted) -
2085
2086
#
2086
2087
# <%= fields_for @person.permission do |permission_fields| %>
2087
- # Admin?: <%= permission_fields.check_box :admin %>
2088
+ # Admin?: <%= permission_fields.checkbox :admin %>
2088
2089
# <% end %>
2089
2090
#
2090
2091
# and +fields_for+ will derive the required name of the field from the
@@ -2102,7 +2103,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2102
2103
# <%= form_with model: @person do |person_form| %>
2103
2104
# ...
2104
2105
# <%= fields_for :permission, @person.permission, {} do |permission_fields| %>
2105
- # Admin?: <%= check_box_tag permission_fields.field_name(:admin), @person.permission[:admin] %>
2106
+ # Admin?: <%= checkbox_tag permission_fields.field_name(:admin), @person.permission[:admin] %>
2106
2107
# <% end %>
2107
2108
# ...
2108
2109
# <% end %>
@@ -2177,7 +2178,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2177
2178
# ...
2178
2179
# <%= person_form.fields_for :address do |address_fields| %>
2179
2180
# ...
2180
- # Delete: <%= address_fields.check_box :_destroy %>
2181
+ # Delete: <%= address_fields.checkbox :_destroy %>
2181
2182
# <% end %>
2182
2183
# ...
2183
2184
# <% end %>
@@ -2265,7 +2266,7 @@ def #{selector}(method, options = {}) # def text_field(method, options = {})
2265
2266
# <%= form_with model: @person do |person_form| %>
2266
2267
# ...
2267
2268
# <%= person_form.fields_for :projects do |project_fields| %>
2268
- # Delete: <%= project_fields.check_box :_destroy %>
2269
+ # Delete: <%= project_fields.checkbox :_destroy %>
2269
2270
# <% end %>
2270
2271
# ...
2271
2272
# <% end %>
@@ -2444,36 +2445,37 @@ def label(method, text = nil, options = {}, &block)
2444
2445
# within an array-like parameter, as in
2445
2446
#
2446
2447
# <%= fields_for "project[invoice_attributes][]", invoice, index: nil do |form| %>
2447
- # <%= form.check_box :paid %>
2448
+ # <%= form.checkbox :paid %>
2448
2449
# ...
2449
2450
# <% end %>
2450
2451
#
2451
2452
# because parameter name repetition is precisely what \Rails seeks to distinguish
2452
2453
# the elements of the array. For each item with a checked check box you
2453
2454
# get an extra ghost item with only that attribute, assigned to "0".
2454
2455
#
2455
- # In that case it is preferable to either use +check_box_tag + or to use
2456
+ # In that case it is preferable to either use +checkbox_tag + or to use
2456
2457
# hashes instead of arrays.
2457
2458
#
2458
2459
# ==== Examples
2459
2460
#
2460
2461
# # Let's say that @article.validated? is 1:
2461
- # check_box ("validated")
2462
+ # checkbox ("validated")
2462
2463
# # => <input name="article[validated]" type="hidden" value="0" />
2463
2464
# # <input checked="checked" type="checkbox" id="article_validated" name="article[validated]" value="1" />
2464
2465
#
2465
2466
# # Let's say that @puppy.gooddog is "no":
2466
- # check_box ("gooddog", {}, "yes", "no")
2467
+ # checkbox ("gooddog", {}, "yes", "no")
2467
2468
# # => <input name="puppy[gooddog]" type="hidden" value="no" />
2468
2469
# # <input type="checkbox" id="puppy_gooddog" name="puppy[gooddog]" value="yes" />
2469
2470
#
2470
2471
# # Let's say that @eula.accepted is "no":
2471
- # check_box ("accepted", { class: 'eula_check' }, "yes", "no")
2472
+ # checkbox ("accepted", { class: 'eula_check' }, "yes", "no")
2472
2473
# # => <input name="eula[accepted]" type="hidden" value="no" />
2473
2474
# # <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 )
2475
+ def checkbox ( method , options = { } , checked_value = "1" , unchecked_value = "0" )
2476
+ @template . checkbox ( @object_name , method , objectify_options ( options ) , checked_value , unchecked_value )
2476
2477
end
2478
+ alias_method :check_box , :checkbox
2477
2479
2478
2480
# Returns a radio button tag for accessing a specified attribute (identified by +method+) on an object
2479
2481
# assigned to the template (identified by +object+). If the current value of +method+ is +tag_value+ the
0 commit comments