Ruby-on-rails 如何禁用rails中的选择选项?

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/3055428/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-09-02 22:48:11  来源:igfitidea点击:

how to disable select option in rails?

ruby-on-rails

提问by Sumeru Suresh

<%=f.select :action_item_status,action_item_status%> 

How can i disable all the option in this select option.

如何禁用此选择选项中的所有选项。

回答by Ju Nogueira

<%= f.select :action_item_status, action_item_status, {}, {:disabled => true} %> 

回答by Markus Andreas

f.select :action_item_status, action_item_status, {}, disabled: true

As I cant comment to the last comment, your mistake is, that disabled has to be in the fourth not the third param.

由于我无法评论最后一条评论,您的错误是,禁用必须在第四个而不是第三个参数中。

So make sure you add a empty one!

所以一定要添加一个空的!

回答by Zernel

<%= f.select :status, STATUSES.map{|s| [s.titleize, s]}, { disabled: DISABLED_STATUSES.map{|s| [s.titleize, s]} %>