Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
f86b221a
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,发现更多精彩内容 >>
未验证
提交
f86b221a
编写于
2月 26, 2018
作者:
R
Rafael França
提交者:
GitHub
2月 26, 2018
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #26799 from deraru/support-i18n-key-in-submit-tag
Support i18n key at translation of value in submit tag
上级
19460585
e579c743
变更
4
隐藏空白更改
内联
并排
Showing
4 changed file
with
48 addition
and
3 deletion
+48
-3
actionview/CHANGELOG.md
actionview/CHANGELOG.md
+4
-0
actionview/lib/action_view/helpers/form_helper.rb
actionview/lib/action_view/helpers/form_helper.rb
+6
-1
actionview/test/template/form_helper/form_with_test.rb
actionview/test/template/form_helper/form_with_test.rb
+19
-1
actionview/test/template/form_helper_test.rb
actionview/test/template/form_helper_test.rb
+19
-1
未找到文件。
actionview/CHANGELOG.md
浏览文件 @
f86b221a
## Rails 6.0.0.alpha (Unreleased) ##
*
Change translation key of
`submit_tag`
from
`module_name_class_name`
to
`module_name/class_name`
.
*Rui Onodera*
*
Rails 6 requires Ruby 2.4.1 or newer.
*Jeremy Daer*
...
...
actionview/lib/action_view/helpers/form_helper.rb
浏览文件 @
f86b221a
...
...
@@ -2266,7 +2266,12 @@ def submit_default_value
end
defaults
=
[]
defaults
<<
:"helpers.submit.
#{
object_name
}
.
#{
key
}
"
# Object is a model and it is not overwritten by as and scope option.
if
object
.
respond_to?
(
:model_name
)
&&
object_name
.
to_s
==
model
.
downcase
defaults
<<
:"helpers.submit.
#{
object
.
model_name
.
i18n_key
}
.
#{
key
}
"
else
defaults
<<
:"helpers.submit.
#{
object_name
}
.
#{
key
}
"
end
defaults
<<
:"helpers.submit.
#{
key
}
"
defaults
<<
"
#{
key
.
to_s
.
humanize
}
#{
model
}
"
...
...
actionview/test/template/form_helper/form_with_test.rb
浏览文件 @
f86b221a
...
...
@@ -190,6 +190,9 @@ def form_with(*)
submit:
"Save changes"
,
another_post:
{
update:
"Update your %{model}"
},
"blog/post"
:
{
update:
"Update your %{model}"
}
}
}
...
...
@@ -962,7 +965,7 @@ def test_submit_without_object_and_locale_strings
end
end
def
test_submit_with_object_
and_nested_lookup
def
test_submit_with_object_
which_is_overwritten_by_scope_option
with_locale
:submit
do
form_with
(
model:
@post
,
scope: :another_post
)
do
|
f
|
concat
f
.
submit
...
...
@@ -976,6 +979,21 @@ def test_submit_with_object_and_nested_lookup
end
end
def
test_submit_with_object_which_is_namespaced
blog_post
=
Blog
::
Post
.
new
(
"And his name will be forty and four."
,
44
)
with_locale
:submit
do
form_with
(
model:
blog_post
)
do
|
f
|
concat
f
.
submit
end
expected
=
whole_form
(
"/posts/44"
,
method:
"patch"
)
do
"<input name='commit' data-disable-with='Update your Post' type='submit' value='Update your Post' />"
end
assert_dom_equal
expected
,
output_buffer
end
end
def
test_fields_with_attributes_not_on_model
form_with
(
model:
@post
)
do
|
f
|
concat
f
.
fields
(
:comment
)
{
|
c
|
...
...
actionview/test/template/form_helper_test.rb
浏览文件 @
f86b221a
...
...
@@ -68,6 +68,9 @@ def form_for(*)
submit:
"Save changes"
,
another_post:
{
update:
"Update your %{model}"
},
"blog/post"
:
{
update:
"Update your %{model}"
}
}
}
...
...
@@ -2271,7 +2274,7 @@ def test_submit_without_object_and_locale_strings
end
end
def
test_submit_with_object_
and_nested_lookup
def
test_submit_with_object_
which_is_overwritten_by_as_option
with_locale
:submit
do
form_for
(
@post
,
as: :another_post
)
do
|
f
|
concat
f
.
submit
...
...
@@ -2285,6 +2288,21 @@ def test_submit_with_object_and_nested_lookup
end
end
def
test_submit_with_object_which_is_namespaced
blog_post
=
Blog
::
Post
.
new
(
"And his name will be forty and four."
,
44
)
with_locale
:submit
do
form_for
(
blog_post
)
do
|
f
|
concat
f
.
submit
end
expected
=
whole_form
(
"/posts/44"
,
"edit_post_44"
,
"edit_post"
,
method:
"patch"
)
do
"<input name='commit' data-disable-with='Update your Post' type='submit' value='Update your Post' />"
end
assert_dom_equal
expected
,
output_buffer
end
end
def
test_nested_fields_for
@comment
.
body
=
"Hello World"
form_for
(
@post
)
do
|
f
|
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录