提交 7e375afb 编写于 作者: S Santiago Pastorino

Merge pull request #17702 from tgxworld/fix_select_tag_include_blank_false

Fix select_tag generating tag when set to false.
......@@ -140,7 +140,9 @@ def select_tag(name, option_tags = nil, options = {})
include_blank = ''
end
option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags)
if include_blank
option_tags = content_tag(:option, include_blank, value: '').safe_concat(option_tags)
end
end
if prompt = options.delete(:prompt)
......
......@@ -232,6 +232,12 @@ def test_select_tag_with_include_blank
assert_dom_equal expected, actual
end
def test_select_tag_with_include_blank_false
actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>".html_safe, include_blank: false
expected = %(<select id="places" name="places"><option>Home</option><option>Work</option><option>Pub</option></select>)
assert_dom_equal expected, actual
end
def test_select_tag_with_include_blank_string
actual = select_tag "places", "<option>Home</option><option>Work</option><option>Pub</option>".html_safe, include_blank: 'Choose'
expected = %(<select id="places" name="places"><option value="">Choose</option><option>Home</option><option>Work</option><option>Pub</option></select>)
......
Markdown is supported
0% .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册