1

How would one set:id => "myvalue" 用于简单形式的集合输入字段?或者在旁注中,我还试图设置age_from的ID,如id =>“age_from”无法弄清楚如何做到这两点,似乎非常缺乏这些文档。

尝试了我能想到的所有可能的组合:

= f.input_field :age_to,
  :label => "Age from",
  :collection => 18..60,
  :select => 19 <------- set this to '19' for this collection?
  :style => "width: 50px !important",
  :id => "myid" <------- how to set id for this collection?
4

3 回答 3

6
f.input_field :age_to, :label => "年龄从", :collection => 18..60,
:selected => 19, :style => "width: 50px !important", :input_html => { :id => "myid" }

希望它可以设置id和显示选定的值!!!

于 2012-08-30T18:45:22.103 回答
1

如果您使用的是 SimpleForm,则:

= f.input :age_to, .., :input_html => { :id => 'myid' }
于 2012-08-30T18:44:12.360 回答
1

尝试:

= f.input :age_to, :label => "Age from", :collection => 18..60, :value_method => 19, :input_html => { :id => 'myid' }
于 2012-08-30T18:46:51.037 回答