Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
0b0ac5d9
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,发现更多精彩内容 >>
提交
0b0ac5d9
编写于
9月 22, 2013
作者:
V
Vasiliy Ermolovich
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
handle `:namespace` form option in collection labels
上级
80008352
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
43 addition
and
1 deletion
+43
-1
actionview/CHANGELOG.md
actionview/CHANGELOG.md
+4
-0
actionview/lib/action_view/helpers/tags/collection_helpers.rb
...onview/lib/action_view/helpers/tags/collection_helpers.rb
+2
-1
actionview/lib/action_view/helpers/tags/label.rb
actionview/lib/action_view/helpers/tags/label.rb
+1
-0
actionview/test/template/form_helper_test.rb
actionview/test/template/form_helper_test.rb
+36
-0
未找到文件。
actionview/CHANGELOG.md
浏览文件 @
0b0ac5d9
*
Handle
`:namespace`
form option in collection labels
*Vasiliy Ermolovich*
*
Fix
`form_for`
when both
`namespace`
and
`as`
options are present
`as` option no longer overwrites `namespace` option when generating
...
...
actionview/lib/action_view/helpers/tags/collection_helpers.rb
浏览文件 @
0b0ac5d9
...
...
@@ -18,7 +18,8 @@ def initialize(template_object, object_name, method_name, object,
end
def
label
(
label_html_options
=
{},
&
block
)
@template_object
.
label
(
@object_name
,
@sanitized_attribute_name
,
@text
,
label_html_options
,
&
block
)
html_options
=
label_html_options
.
merge
(
@input_html_options
)
@template_object
.
label
(
@object_name
,
@sanitized_attribute_name
,
@text
,
html_options
,
&
block
)
end
end
...
...
actionview/lib/action_view/helpers/tags/label.rb
浏览文件 @
0b0ac5d9
...
...
@@ -30,6 +30,7 @@ def render(&block)
add_default_name_and_id_for_value
(
tag_value
,
name_and_id
)
options
.
delete
(
"index"
)
options
.
delete
(
"namespace"
)
options
.
delete
(
"multiple"
)
options
[
"for"
]
=
name_and_id
[
"id"
]
unless
options
.
key?
(
"for"
)
if
block_given?
...
...
actionview/test/template/form_helper_test.rb
浏览文件 @
0b0ac5d9
...
...
@@ -1282,6 +1282,24 @@ def post.id; 1; end
assert_dom_equal
expected
,
output_buffer
end
def
test_form_with_namespace_and_with_collection_radio_buttons
post
=
Post
.
new
def
post
.
active
;
false
;
end
form_for
(
post
,
namespace:
'foo'
)
do
|
f
|
concat
f
.
collection_radio_buttons
(
:active
,
[
true
,
false
],
:to_s
,
:to_s
)
end
expected
=
whole_form
(
"/posts"
,
"foo_new_post"
,
"new_post"
)
do
"<input id='foo_post_active_true' name='post[active]' type='radio' value='true' />"
+
"<label for='foo_post_active_true'>true</label>"
+
"<input checked='checked' id='foo_post_active_false' name='post[active]' type='radio' value='false' />"
+
"<label for='foo_post_active_false'>false</label>"
end
assert_dom_equal
expected
,
output_buffer
end
def
test_form_for_with_collection_check_boxes
post
=
Post
.
new
def
post
.
tag_ids
;
[
1
,
3
];
end
...
...
@@ -1361,6 +1379,24 @@ def post.id; 1; end
assert_dom_equal
expected
,
output_buffer
end
def
test_form_with_namespace_and_with_collection_check_boxes
post
=
Post
.
new
def
post
.
tag_ids
;
[
1
];
end
collection
=
[[
1
,
"Tag 1"
]]
form_for
(
post
,
namespace:
'foo'
)
do
|
f
|
concat
f
.
collection_check_boxes
(
:tag_ids
,
collection
,
:first
,
:last
)
end
expected
=
whole_form
(
"/posts"
,
"foo_new_post"
,
"new_post"
)
do
"<input checked='checked' id='foo_post_tag_ids_1' name='post[tag_ids][]' type='checkbox' value='1' />"
+
"<label for='foo_post_tag_ids_1'>Tag 1</label>"
+
"<input name='post[tag_ids][]' type='hidden' value='' />"
end
assert_dom_equal
expected
,
output_buffer
end
def
test_form_for_with_file_field_generate_multipart
Post
.
send
:attr_accessor
,
:file
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录