I wan't to disable a collection_select and already tested the followings code:
<%= f.collection_select(:categoria_id, Categoria.order(:descricao), :id, :descricao,{ class: "form-control", :disabled => "disabled" }) %>
<%= f.collection_select(:categoria_id, Categoria.order(:descricao), :id, :descricao,{ class: "form-control", :disabled => true }) %>
<%= f.collection_select(:categoria_id, Categoria.order(:descricao), :id, :descricao, class: "form-control", :disabled => "disabled") %>
<%= f.collection_select(:categoria_id, Categoria.order(:descricao), :id, :descricao, class: "form-control", :disabled => true) %>
None of them work, anyone know why?
From rails documentation
collection_select(object, method, collection, value_method, text_method, options = {}, html_options = {}) public
Note there is a option attribute before the html options attribute. If you are not defining any options then you have to include a empty braces before defining any html options.
<%= f.collection_select(:categoria_id, Categoria.order(:descricao), :id, :descricao,{},{ class: "form-control", :disabled => "disabled" }) %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With