Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f7669cd8
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,发现更多精彩内容 >>
提交
f7669cd8
编写于
12月 24, 2011
作者:
V
Vasiliy Ermolovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
add ability to set a prompt string in include_blank option for date helpers, closes #4143
上级
4d8ee288
变更
2
隐藏空白更改
内联
并排
Showing
2 changed file
with
22 addition
and
2 deletion
+22
-2
actionpack/lib/action_view/helpers/date_helper.rb
actionpack/lib/action_view/helpers/date_helper.rb
+2
-2
actionpack/test/template/date_helper_test.rb
actionpack/test/template/date_helper_test.rb
+20
-0
未找到文件。
actionpack/lib/action_view/helpers/date_helper.rb
浏览文件 @
f7669cd8
...
...
@@ -13,7 +13,7 @@ module Helpers
#
# * <tt>:prefix</tt> - overwrites the default prefix of "date" used for the select names. So specifying "birthday"
# would give birthday[month] instead of date[month] if passed to the <tt>select_month</tt> method.
# * <tt>:include_blank</tt> - set to true if it should be possible to set an empty date.
# * <tt>:include_blank</tt> - set to true
or to a prompt string
if it should be possible to set an empty date.
# * <tt>:discard_type</tt> - set to true if you want to discard the type part of the select name. If set to true,
# the <tt>select_month</tt> method would use simply "date" (which can be overwritten using <tt>:prefix</tt>) instead
# of "date[month]".
...
...
@@ -887,7 +887,7 @@ def build_select(type, select_options_as_html)
select_options
.
merge!
(
:disabled
=>
'disabled'
)
if
@options
[
:disabled
]
select_html
=
"
\n
"
select_html
<<
content_tag
(
:option
,
''
,
:value
=>
''
)
+
"
\n
"
if
@options
[
:include_blank
]
select_html
<<
content_tag
(
:option
,
"
#{
ERB
::
Util
.
html_escape
(
@options
[
:include_blank
])
if
@options
[
:include_blank
].
kind_of?
(
String
)
}
"
,
:value
=>
''
)
+
"
\n
"
if
@options
[
:include_blank
]
select_html
<<
prompt_option_tag
(
type
,
@options
[
:prompt
])
+
"
\n
"
if
@options
[
:prompt
]
select_html
<<
select_options_as_html
...
...
actionpack/test/template/date_helper_test.rb
浏览文件 @
f7669cd8
...
...
@@ -1581,6 +1581,26 @@ def test_date_select_with_nil_and_blank
assert_dom_equal
expected
,
date_select
(
"post"
,
"written_on"
,
:include_blank
=>
true
)
end
def
test_date_select_with_stringified_blank
@post
=
Post
.
new
start_year
=
Time
.
now
.
year
-
5
end_year
=
Time
.
now
.
year
+
5
expected
=
'<input name="post[written_on(3i)]" type="hidden" id="post_written_on_3i"/>'
+
"
\n
"
expected
<<
%{<select id="post_written_on_1i" name="post[written_on(1i)]">\n}
expected
<<
"<option value=
\"\"
>blank</option>
\n
"
start_year
.
upto
(
end_year
)
{
|
i
|
expected
<<
%(<option value="#{i}">#{i}</option>\n)
}
expected
<<
"</select>
\n
"
expected
<<
%{<select id="post_written_on_2i" name="post[written_on(2i)]">\n}
expected
<<
"<option value=
\"\"
>blank</option>
\n
"
1
.
upto
(
12
)
{
|
i
|
expected
<<
%(<option value="#{i}">#{Date::MONTHNAMES[i]}</option>\n)
}
expected
<<
"</select>
\n
"
assert_dom_equal
expected
,
date_select
(
"post"
,
"written_on"
,
:order
=>
[
:year
,
:month
],
:include_blank
=>
'blank'
)
end
def
test_date_select_with_nil_and_blank_and_order
@post
=
Post
.
new
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录