HAML 选择帮助程序未正确排序选项
我正在尝试获取一些表单,但遇到了麻烦,因为 HAML 没有正确排序我的选择元素中的选项。
这是我的 echo 语句:
=select 'user', @empty_data, {"Less than $40k" => 1, "$40k - $70k" => 2, "$70k - $100k" => 3, "$100k+" => 4, "No Thanks" => 5 }
但是,当呈现 HTML 时,选项没有任何可辨别的顺序,更不用说我放置它们的顺序了。是否有什么我做得不正确?
谢谢
I'm trying to get some forms out, but I'm having trouble, in that HAML is not ordering the options in my select elements properly.
Here is my echo statement:
=select 'user', @empty_data, {"Less than $40k" => 1, "$40k - $70k" => 2, "$70k - $100k" => 3, "$100k+" => 4, "No Thanks" => 5 }
However, when the HTML gets rendered, the options are not in any discernible order, let alone the order I placed them in. Is there something I'm not doing correctly?
Thank you
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
这是因为选项列表是列表的列表。不是哈希
请参阅有关此帮助程序的文档:
http://api. rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M002302
It's because the list of option is a list of list. Not a Hash
See the documentation about this helper :
http://api.rubyonrails.org/classes/ActionView/Helpers/FormOptionsHelper.html#M002302