Wondering if there is a way to disable only the first nil option in a list of options. There are multiple options with nil values.
For example if we have
options_for_select(
[["first", nil],
["second", "second"],
["third", "third"],
["fourth", nil]])
It generates
<option name="first" value>first</option>
<option name="second" value="second">Second</option>
<option name="third" value="third">Third</option>
<option name="fourth" value>Fourth</option>
and passing in the disabled values will disable all values with nil
options_for_select(
[["first", nil],
["second", "second"],
["third", "third"],
["fourth", nil]] , :disabled=>"")
<option name="first" value disabled>first</option>
<option name="second" value="second">Second</option>
<option name="third" value="third">Third</option>
<option name="fourth" value disabled>Fourth</option>
Anyway I can specify one the first option to be disabled regardless of value? The end goal is to have
<option name="first" value disabled>first</option>
<option name="second" value="second">Second</option>
<option name="third" value="third">Third</option>
<option name="fourth" value>Fourth</option>
you can update your values and pass to option_for_select helper.
In above example first of all i select all the nil value from the array and then i select the first nil value and pass that value to the disable variable. Now you can pass the
arrvariable to the helperHope this works for you.