mirror of
https://github.com/rails/rails.git
synced 2022-11-09 12:12:34 -05:00
Fixed #select form builder helper to support block with html output
This commit is contained in:
parent
3300fdedc7
commit
7a0c2ba48b
2 changed files with 14 additions and 1 deletions
|
@ -3,7 +3,7 @@ module ActionView
|
|||
module Tags # :nodoc:
|
||||
class Select < Base # :nodoc:
|
||||
def initialize(object_name, method_name, template_object, choices, options, html_options)
|
||||
@choices = block_given? ? template_object.capture { yield } : choices
|
||||
@choices = block_given? ? template_object.capture { yield || "" } : choices
|
||||
@choices = @choices.to_a if @choices.is_a?(Range)
|
||||
|
||||
@html_options = html_options
|
||||
|
|
|
@ -591,6 +591,19 @@ class FormOptionsHelperTest < ActionView::TestCase
|
|||
)
|
||||
end
|
||||
|
||||
def test_select_under_fields_for_with_block_without_options
|
||||
@post = Post.new
|
||||
|
||||
output_buffer = fields_for :post, @post do |f|
|
||||
concat(f.select(:category) {})
|
||||
end
|
||||
|
||||
assert_dom_equal(
|
||||
"<select id=\"post_category\" name=\"post[category]\"></select>",
|
||||
output_buffer
|
||||
)
|
||||
end
|
||||
|
||||
def test_select_with_multiple_to_add_hidden_input
|
||||
output_buffer = select(:post, :category, "", {}, :multiple => true)
|
||||
assert_dom_equal(
|
||||
|
|
Loading…
Reference in a new issue