如何在rails中禁用select选项?

时间:2022-12-24 19:42:43
<%=f.select :action_item_status,action_item_status%> 

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

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

3 个解决方案

#1


51  

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

#2


3  

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

#3


1  

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!

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

#1


51  

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

#2


3  

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

#3


1  

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!

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