Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
89dc4813
R
rails
项目概览
张重言
/
rails
通知
1
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
R
rails
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
89dc4813
编写于
7月 10, 2012
作者:
R
Rafael Mendonça França
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #7026 from rustygeldmacher/select_options_valid_html_master
Fixed bug creating invalid HTML in select options
上级
d7b8f0c0
1a935ad7
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
17 addition
and
3 deletion
+17
-3
actionpack/lib/action_view/helpers/form_options_helper.rb
actionpack/lib/action_view/helpers/form_options_helper.rb
+1
-1
actionpack/lib/action_view/helpers/tags/base.rb
actionpack/lib/action_view/helpers/tags/base.rb
+2
-2
actionpack/test/template/active_model_helper_test.rb
actionpack/test/template/active_model_helper_test.rb
+14
-0
未找到文件。
actionpack/lib/action_view/helpers/form_options_helper.rb
浏览文件 @
89dc4813
...
...
@@ -353,7 +353,7 @@ def options_for_select(container, selected = nil)
html_attributes
[
:disabled
]
=
'disabled'
if
disabled
&&
option_value_selected?
(
value
,
disabled
)
html_attributes
[
:value
]
=
value
content_tag
(
:option
,
text
,
html_attributes
)
content_tag
_string
(
:option
,
text
,
html_attributes
)
end
.
join
(
"
\n
"
).
html_safe
end
...
...
actionpack/lib/action_view/helpers/tags/base.rb
浏览文件 @
89dc4813
...
...
@@ -137,10 +137,10 @@ def select_not_required?(html_options)
def
add_options
(
option_tags
,
options
,
value
=
nil
)
if
options
[
:include_blank
]
option_tags
=
content_tag
(
'option'
,
options
[
:include_blank
].
kind_of?
(
String
)
?
options
[
:include_blank
]
:
nil
,
:value
=>
''
)
+
"
\n
"
+
option_tags
option_tags
=
content_tag
_string
(
'option'
,
options
[
:include_blank
].
kind_of?
(
String
)
?
options
[
:include_blank
]
:
nil
,
:value
=>
''
)
+
"
\n
"
+
option_tags
end
if
value
.
blank?
&&
options
[
:prompt
]
option_tags
=
content_tag
(
'option'
,
prompt_text
(
options
[
:prompt
]),
:value
=>
''
)
+
"
\n
"
+
option_tags
option_tags
=
content_tag
_string
(
'option'
,
prompt_text
(
options
[
:prompt
]),
:value
=>
''
)
+
"
\n
"
+
option_tags
end
option_tags
end
...
...
actionpack/test/template/active_model_helper_test.rb
浏览文件 @
89dc4813
...
...
@@ -41,6 +41,19 @@ def test_text_field_with_errors
)
end
def
test_select_with_errors
assert_dom_equal
(
%(<div class="field_with_errors"><select name="post[author_name]" id="post_author_name"><option value="a">a</option>\n<option value="b">b</option></select></div>)
,
select
(
"post"
,
"author_name"
,
[
:a
,
:b
])
)
end
def
test_select_with_errors_and_blank_option
expected_dom
=
%(<div class="field_with_errors"><select name="post[author_name]" id="post_author_name"><option value="">Choose one...</option>\n<option value="a">a</option>\n<option value="b">b</option></select></div>)
assert_dom_equal
(
expected_dom
,
select
(
"post"
,
"author_name"
,
[
:a
,
:b
],
:include_blank
=>
'Choose one...'
))
assert_dom_equal
(
expected_dom
,
select
(
"post"
,
"author_name"
,
[
:a
,
:b
],
:prompt
=>
'Choose one...'
))
end
def
test_date_select_with_errors
assert_dom_equal
(
%(<div class="field_with_errors"><select id="post_updated_at_1i" name="post[updated_at(1i)]">\n<option selected="selected" value="2004">2004</option>\n<option value="2005">2005</option>\n</select>\n<input id="post_updated_at_2i" name="post[updated_at(2i)]" type="hidden" value="6" />\n<input id="post_updated_at_3i" name="post[updated_at(3i)]" type="hidden" value="1" />\n</div>)
,
...
...
@@ -82,4 +95,5 @@ def test_field_error_proc
ensure
ActionView
::
Base
.
field_error_proc
=
old_proc
if
old_proc
end
end
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录