: disabled field does not work in fields_for

I am trying to add a drop-down list of disabled ones to my table, which I will eventually make conditional. However, the disconnected does not seem to be added to the line when it starts.

If I check the item on the page, it manually adds disabled works, but it is not added at runtime.

= f.fields_for(:targets, qualification.target_for(@grandfather.user)) do |builder| %tr %td = builder.select :completed, qualification.level_options.map{|o| [o,o]}, :disabled => "disabled" = builder.hidden_field :qualification_id, :value => qualification.id = builder.hidden_field :id 
+4
source share
1 answer

Check out the Rails API API. Form API

 select(object, method, choices, options = {}, html_options = {}) 

Added :disabled => "disabled" to the parameters instead of html_options. Instead, the code is used (note the empty hash for the options parameter):

 builder.select(:completed, qualification.level_options.map{|o| [o,o]}, {}, {:disabled => "disabled"}) 
+3
source

Source: https://habr.com/ru/post/1379322/


All Articles