Rails:手动更改 select() 帮助器中的选择顺序?
我有以下 select()
表单帮助器方法:
select("treatment", "frequency_unit", { "hour" => "hour", "day" => "day", "week" => "week", "month" => "month", "year" => "year" })
该帮助器看似随机地组织选择...我希望它能够保持上面列出的选择顺序。
我怎样才能做到这一点?
这是上面代码的输出:
<select id="treatment_frequency_unit" name="treatment[frequency_unit]">
<option value="month">month</option>
<option value="week">week</option>
<option value="hour">hour</option>
<option value="day">day</option>
<option value="year">year</option>
</select>
I've got the following select()
form helper method:
select("treatment", "frequency_unit", { "hour" => "hour", "day" => "day", "week" => "week", "month" => "month", "year" => "year" })
The helper is organizing the choices seemingly randomly...I'd like it to maintain the order of the choices as I have them listed above.
How can I make that happen?
Here's the output of the code above:
<select id="treatment_frequency_unit" name="treatment[frequency_unit]">
<option value="month">month</option>
<option value="week">week</option>
<option value="hour">hour</option>
<option value="day">day</option>
<option value="year">year</option>
</select>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
使用数组代替哈希
Instead of the hash, go for an array