我有一个选择助手,如下所示,我已禁用它,并希望给予" 1"作为默认值,但无法找到?
<%= f.select :fuel_incl, [[t('shared.incl'),'1'],[t('shared.notInc'),'0']], {}, {class: "Select-control u-sizeFull fuel_incl", :disabled => true} %>
它被禁用,所以它应该选择1作为默认值。
修改
我看到它可以在控制台上运行;
<select class="Select-control u-sizeFull fuel_incl" disabled="disabled" name="boat[fuel_incl]" id="boat_fuel_incl">
<option selected="selected" value="1">Included</option>
<option value="0">Not Included</option></select>
但它不发送为params,当我取出禁用true并选择值发送表单时,它可以工作..
EDIT2
无论如何,我只通过给出一个选择值来解决它;
<%= f.select :fuel_incl,
[[t('shared.incl'),'1']],
{ selected: '1' },
{ class: "Select-control u-sizeFull fuel_incl" } %>
答案 0 :(得分:1)
添加selected
选项:
<%= f.select :fuel_incl,
[[t('shared.incl'),'1'],[t('shared.notInc'),'0']],
{ selected: '1' },
{ class: "Select-control u-sizeFull fuel_incl", disabled: true } %>