aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers/form_options_helper.rb
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-01 19:46:48 -0200
committerRafael Mendonça França <rafaelmfranca@gmail.com>2012-02-02 14:52:33 -0200
commit0f234261552dae68b66d3d0271ef39c343082c36 (patch)
tree2931d9b467e0fd403ff64df26da14a2bc2f4d6a4 /actionpack/lib/action_view/helpers/form_options_helper.rb
parentf506c8063b3084f54aa8bd157d94f10b7aed2bf0 (diff)
downloadrails-0f234261552dae68b66d3d0271ef39c343082c36.tar.gz
rails-0f234261552dae68b66d3d0271ef39c343082c36.tar.bz2
rails-0f234261552dae68b66d3d0271ef39c343082c36.zip
Allow collection radio_buttons/check_boxes to access current text/value
[Carlos Antonio da Silva + Rafael Mendonça França]
Diffstat (limited to 'actionpack/lib/action_view/helpers/form_options_helper.rb')
-rw-r--r--actionpack/lib/action_view/helpers/form_options_helper.rb14
1 files changed, 14 insertions, 0 deletions
diff --git a/actionpack/lib/action_view/helpers/form_options_helper.rb b/actionpack/lib/action_view/helpers/form_options_helper.rb
index f3e8de9ce1..c5a738d99f 100644
--- a/actionpack/lib/action_view/helpers/form_options_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_options_helper.rb
@@ -573,6 +573,13 @@ module ActionView
# collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
# b.label(:class => "radio_button") { b.radio_button(:class => "radio_button") }
# end
+ #
+ # There are also two special methods available: <tt>text</tt> and
+ # <tt>value</tt>, which are the current text and value methods for the
+ # item being rendered, respectively. You can use them like this:
+ # collection_radio_buttons(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
+ # b.label(:"data-value" => b.value) { b.radio_button + b.text }
+ # end
def collection_radio_buttons(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
Tags::CollectionRadioButtons.new(object, method, self, collection, value_method, text_method, options, html_options).render(&block)
end
@@ -629,6 +636,13 @@ module ActionView
# collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
# b.label(:class => "check_box") { b.check_box(:class => "check_box") }
# end
+ #
+ # There are also two special methods available: <tt>text</tt> and
+ # <tt>value</tt>, which are the current text and value methods for the
+ # item being rendered, respectively. You can use them like this:
+ # collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial) do |b|
+ # b.label(:"data-value" => b.value) { b.check_box + b.text }
+ # end
def collection_check_boxes(object, method, collection, value_method, text_method, options = {}, html_options = {}, &block)
Tags::CollectionCheckBoxes.new(object, method, self, collection, value_method, text_method, options, html_options).render(&block)
end