aboutsummaryrefslogtreecommitdiffstats
path: root/actionpack/lib/action_view/helpers
diff options
context:
space:
mode:
authorCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-01 01:18:06 -0200
committerCarlos Antonio da Silva <carlosantoniodasilva@gmail.com>2012-02-02 09:40:24 -0200
commitb17be2938c4a05d29226e0dc189251014ccd5d2c (patch)
tree716f6cae8f67c9bec40426f2482aa9c61ca88f2d /actionpack/lib/action_view/helpers
parent471b8554911e65bfbfc5c259f775cb7dac375c88 (diff)
downloadrails-b17be2938c4a05d29226e0dc189251014ccd5d2c.tar.gz
rails-b17be2938c4a05d29226e0dc189251014ccd5d2c.tar.bz2
rails-b17be2938c4a05d29226e0dc189251014ccd5d2c.zip
Remove collection_wrapper* and item_wrapper* options
[Carlos Antonio da Silva + Rafael Mendonça França]
Diffstat (limited to 'actionpack/lib/action_view/helpers')
-rw-r--r--actionpack/lib/action_view/helpers/form_collections_helper.rb36
-rw-r--r--actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb2
-rw-r--r--actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb22
3 files changed, 15 insertions, 45 deletions
diff --git a/actionpack/lib/action_view/helpers/form_collections_helper.rb b/actionpack/lib/action_view/helpers/form_collections_helper.rb
index da89a23552..d3d1ac18d3 100644
--- a/actionpack/lib/action_view/helpers/form_collections_helper.rb
+++ b/actionpack/lib/action_view/helpers/form_collections_helper.rb
@@ -24,18 +24,12 @@ module ActionView
# collection_radio_buttons(:post, :author_id, Author.all, :id, :name_with_initial)
#
# If <tt>@post.author_id</tt> is already <tt>1</tt>, this would return:
- # <span>
- # <input id="post_author_id_1" name="post[author_id]" type="radio" value="1" checked="checked" />
- # <label class="collection_radio_buttons" for="post_author_id_1">D. Heinemeier Hansson</label>
- # </span>
- # <span>
- # <input id="post_author_id_2" name="post[author_id]" type="radio" value="2" />
- # <label class="collection_radio_buttons" for="post_author_id_2">D. Thomas</label>
- # </span>
- # <span>
- # <input id="post_author_id_3" name="post[author_id]" type="radio" value="3" />
- # <label class="collection_radio_buttons" for="post_author_id_3">M. Clark</label>
- # </span>
+ # <input id="post_author_id_1" name="post[author_id]" type="radio" value="1" checked="checked" />
+ # <label class="collection_radio_buttons" for="post_author_id_1">D. Heinemeier Hansson</label>
+ # <input id="post_author_id_2" name="post[author_id]" type="radio" value="2" />
+ # <label class="collection_radio_buttons" for="post_author_id_2">D. Thomas</label>
+ # <input id="post_author_id_3" name="post[author_id]" type="radio" value="3" />
+ # <label class="collection_radio_buttons" for="post_author_id_3">M. Clark</label>
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
@@ -63,18 +57,12 @@ module ActionView
# collection_check_boxes(:post, :author_ids, Author.all, :id, :name_with_initial)
#
# If <tt>@post.author_ids</tt> is already <tt>[1]</tt>, this would return:
- # <span>
- # <input id="post_author_ids_1" name="post[author_ids][]" type="checkbox" value="1" checked="checked" />
- # <label class="collection_check_boxes" for="post_author_ids_1">D. Heinemeier Hansson</label>
- # </span>
- # <span>
- # <input id="post_author_ids_1" name="post[author_ids][]" type="checkbox" value="2" />
- # <label class="collection_check_boxes" for="post_author_ids_1">D. Thomas</label>
- # </span>
- # <span>
- # <input id="post_author_ids_3" name="post[author_ids][]" type="checkbox" value="3" />
- # <label class="collection_check_boxes" for="post_author_ids_3">M. Clark</label>
- # </span>
+ # <input id="post_author_ids_1" name="post[author_ids][]" type="checkbox" value="1" checked="checked" />
+ # <label class="collection_check_boxes" for="post_author_ids_1">D. Heinemeier Hansson</label>
+ # <input id="post_author_ids_1" name="post[author_ids][]" type="checkbox" value="2" />
+ # <label class="collection_check_boxes" for="post_author_ids_1">D. Thomas</label>
+ # <input id="post_author_ids_3" name="post[author_ids][]" type="checkbox" value="3" />
+ # <label class="collection_check_boxes" for="post_author_ids_3">M. Clark</label>
# <input name="post[author_ids][]" type="hidden" value="" />
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)
diff --git a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb
index 1103341888..7c85441c5d 100644
--- a/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb
+++ b/actionpack/lib/action_view/helpers/tags/collection_check_boxes.rb
@@ -20,7 +20,7 @@ module ActionView
# server if all check boxes are unchecked.
hidden = @template_object.hidden_field_tag(tag_name_multiple, "", :id => nil)
- wrap_rendered_collection(rendered_collection + hidden)
+ rendered_collection + hidden
end
end
end
diff --git a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
index 201eff048c..3d04ae3579 100644
--- a/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
+++ b/actionpack/lib/action_view/helpers/tags/collection_radio_buttons.rb
@@ -5,7 +5,7 @@ module ActionView
delegate :radio_button, :label, :to => :@template_object
def render
- rendered_collection = render_collection do |value, text, default_html_options|
+ render_collection do |value, text, default_html_options|
if block_given?
yield sanitize_attribute_name(value), text, value, default_html_options
else
@@ -13,8 +13,6 @@ module ActionView
label(@object_name, sanitize_attribute_name(value), text, :class => "collection_radio_buttons")
end
end
-
- wrap_rendered_collection(rendered_collection)
end
private
@@ -49,34 +47,18 @@ module ActionView
end
def render_collection #:nodoc:
- item_wrapper_tag = @options.fetch(:item_wrapper_tag, :span)
- item_wrapper_class = @options[:item_wrapper_class]
-
@collection.map do |item|
value = value_for_collection(item, @value_method)
text = value_for_collection(item, @text_method)
default_html_options = default_html_options_for_collection(item, value)
- rendered_item = yield value, text, default_html_options
-
- item_wrapper_tag ? @template_object.content_tag(item_wrapper_tag, rendered_item, :class => item_wrapper_class) : rendered_item
+ yield value, text, default_html_options
end.join.html_safe
end
def value_for_collection(item, value) #:nodoc:
value.respond_to?(:call) ? value.call(item) : item.send(value)
end
-
- def wrap_rendered_collection(collection)
- wrapper_tag = @options[:collection_wrapper_tag]
-
- if wrapper_tag
- wrapper_class = @options[:collection_wrapper_class]
- @template_object.content_tag(wrapper_tag, collection, :class => wrapper_class)
- else
- collection
- end
- end
end
end
end