Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
53eb9fdd
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,体验更适合开发者的 AI 搜索 >>
提交
53eb9fdd
编写于
6月 28, 2013
作者:
J
Jon Rowe
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
fetch value(s) from stringified options
上级
9a26d94d
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
23 addition
and
2 deletion
+23
-2
actionview/CHANGELOG.md
actionview/CHANGELOG.md
+4
-0
actionview/lib/action_view/helpers/tags/color_field.rb
actionview/lib/action_view/helpers/tags/color_field.rb
+1
-1
actionview/lib/action_view/helpers/tags/datetime_field.rb
actionview/lib/action_view/helpers/tags/datetime_field.rb
+1
-1
actionview/test/template/form_helper_test.rb
actionview/test/template/form_helper_test.rb
+17
-0
未找到文件。
actionview/CHANGELOG.md
浏览文件 @
53eb9fdd
*
Pick
`DateField`
`DateTimeField`
and
`ColorField`
values from stringified options allowing use of symbol keys with helpers.
*Jon Rowe*
*
Remove the deprecated
`prompt`
argument from
`grouped_options_for_select`
,
pass in a
`:prompt`
hash option to use this feature.
...
...
actionview/lib/action_view/helpers/tags/color_field.rb
浏览文件 @
53eb9fdd
...
...
@@ -4,7 +4,7 @@ module Tags # :nodoc:
class
ColorField
<
TextField
# :nodoc:
def
render
options
=
@options
.
stringify_keys
options
[
"value"
]
=
@
options
.
fetch
(
"value"
)
{
validate_color_string
(
value
(
object
))
}
options
[
"value"
]
=
options
.
fetch
(
"value"
)
{
validate_color_string
(
value
(
object
))
}
@options
=
options
super
end
...
...
actionview/lib/action_view/helpers/tags/datetime_field.rb
浏览文件 @
53eb9fdd
...
...
@@ -4,7 +4,7 @@ module Tags # :nodoc:
class
DatetimeField
<
TextField
# :nodoc:
def
render
options
=
@options
.
stringify_keys
options
[
"value"
]
=
@
options
.
fetch
(
"value"
)
{
format_date
(
value
(
object
))
}
options
[
"value"
]
=
options
.
fetch
(
"value"
)
{
format_date
(
value
(
object
))
}
options
[
"min"
]
=
format_date
(
options
[
"min"
])
options
[
"max"
]
=
format_date
(
options
[
"max"
])
@options
=
options
...
...
actionview/test/template/form_helper_test.rb
浏览文件 @
53eb9fdd
...
...
@@ -702,6 +702,11 @@ def test_color_field_with_invalid_hex_color_string
assert_dom_equal
(
expected
,
color_field
(
"car"
,
"color"
))
end
def
test_color_field_with_value_attr
expected
=
%{<input id="car_color" name="car[color]" type="color" value="#00FF00" />}
assert_dom_equal
(
expected
,
color_field
(
"car"
,
"color"
,
value:
"#00FF00"
))
end
def
test_search_field
expected
=
%{<input id="contact_notes_query" name="contact[notes_query]" type="search" />}
assert_dom_equal
(
expected
,
search_field
(
"contact"
,
"notes_query"
))
...
...
@@ -732,6 +737,12 @@ def test_date_field_with_extra_attrs
assert_dom_equal
(
expected
,
date_field
(
"post"
,
"written_on"
,
min:
min_value
,
max:
max_value
,
step:
step
))
end
def
test_date_field_with_value_attr
expected
=
%{<input id="post_written_on" name="post[written_on]" type="date" value="2013-06-29" />}
value
=
Date
.
new
(
2013
,
6
,
29
)
assert_dom_equal
(
expected
,
date_field
(
"post"
,
"written_on"
,
value:
value
))
end
def
test_date_field_with_timewithzone_value
previous_time_zone
,
Time
.
zone
=
Time
.
zone
,
'UTC'
expected
=
%{<input id="post_written_on" name="post[written_on]" type="date" value="2004-06-15" />}
...
...
@@ -802,6 +813,12 @@ def test_datetime_field_with_extra_attrs
assert_dom_equal
(
expected
,
datetime_field
(
"post"
,
"written_on"
,
min:
min_value
,
max:
max_value
,
step:
step
))
end
def
test_datetime_field_with_value_attr
expected
=
%{<input id="post_written_on" name="post[written_on]" type="datetime" value="2013-06-29T13:37:00+00:00" />}
value
=
DateTime
.
new
(
2013
,
6
,
29
,
13
,
37
)
assert_dom_equal
(
expected
,
datetime_field
(
"post"
,
"written_on"
,
value:
value
))
end
def
test_datetime_field_with_timewithzone_value
previous_time_zone
,
Time
.
zone
=
Time
.
zone
,
'UTC'
expected
=
%{<input id="post_written_on" name="post[written_on]" type="datetime" value="2004-06-15T15:30:45.000+0000" />}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录