Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
张重言
rails
提交
29054ba1
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 搜索 >>
提交
29054ba1
编写于
2月 25, 2012
作者:
J
José Valim
浏览文件
操作
浏览文件
下载
差异文件
Merge pull request #5117 from nashby/form-option-refactor
FormOptionsHelper refactor
上级
5196c075
50cf5f76
变更
1
隐藏空白更改
内联
并排
Showing
1 changed file
with
11 addition
and
17 deletion
+11
-17
actionpack/lib/action_view/helpers/form_options_helper.rb
actionpack/lib/action_view/helpers/form_options_helper.rb
+11
-17
未找到文件。
actionpack/lib/action_view/helpers/form_options_helper.rb
浏览文件 @
29054ba1
...
...
@@ -506,23 +506,24 @@ def grouped_options_for_select(grouped_options, selected_key = nil, prompt = nil
# NOTE: Only the option tags are returned, you have to wrap this call in
# a regular HTML select tag.
def
time_zone_options_for_select
(
selected
=
nil
,
priority_zones
=
nil
,
model
=
::
ActiveSupport
::
TimeZone
)
zone_options
=
""
zone_options
=
""
.
html_safe
zones
=
model
.
all
convert_zones
=
lambda
{
|
list
|
list
.
map
{
|
z
|
[
z
.
to_s
,
z
.
name
]
}
}
if
priority_zones
if
priority_zones
.
is_a?
(
Regexp
)
priority_zones
=
model
.
all
.
find_all
{
|
z
|
z
=~
priority_zones
}
priority_zones
=
zones
.
select
{
|
z
|
z
=~
priority_zones
}
end
zone_options
+=
options_for_select
(
convert_zones
[
priority_zones
],
selected
)
zone_options
+=
"<option value=
\"\"
disabled=
\"
disabled
\"
>-------------</option>
\n
"
zones
=
zones
.
reject
{
|
z
|
priority_zones
.
include?
(
z
)
}
zone_options
.
safe_concat
options_for_select
(
convert_zones
[
priority_zones
],
selected
)
zone_options
.
safe_concat
content_tag
(
:option
,
'-------------'
,
:value
=>
''
,
:disabled
=>
'disabled'
)
zone_options
.
safe_concat
"
\n
"
zones
.
reject!
{
|
z
|
priority_zones
.
include?
(
z
)
}
end
zone_options
+=
options_for_select
(
convert_zones
[
zones
],
selected
)
zone_options
.
html_safe
zone_options
.
safe_concat
options_for_select
(
convert_zones
[
zones
],
selected
)
end
# Returns radio button tags for the collection of existing return values
...
...
@@ -659,11 +660,8 @@ def option_html_attributes(element)
def
option_text_and_value
(
option
)
# Options are [text, value] pairs or strings used for both.
case
when
Array
===
option
option
=
option
.
reject
{
|
e
|
Hash
===
e
}
[
option
.
first
,
option
.
last
]
when
!
option
.
is_a?
(
String
)
&&
option
.
respond_to?
(
:first
)
&&
option
.
respond_to?
(
:last
)
if
!
option
.
is_a?
(
String
)
&&
option
.
respond_to?
(
:first
)
&&
option
.
respond_to?
(
:last
)
option
=
option
.
reject
{
|
e
|
Hash
===
e
}
if
Array
===
option
[
option
.
first
,
option
.
last
]
else
[
option
,
option
]
...
...
@@ -671,11 +669,7 @@ def option_text_and_value(option)
end
def
option_value_selected?
(
value
,
selected
)
if
selected
.
respond_to?
(
:include?
)
&&
!
selected
.
is_a?
(
String
)
selected
.
include?
value
else
value
==
selected
end
Array
(
selected
).
include?
value
end
def
extract_selected_and_disabled
(
selected
)
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录