Simple_form input as both text and autocomplete

天涯浪子 提交于 2019-12-10 12:06:21

问题


I am using gem 'simple_form', '2.0' and gem 'rails3-jquery-autocomplete', '1.0.10'.

I am unable to make a string field accept two ':as' arguments.

<%= f.input :product_description , :url => autocomplete_product_name_products_path,
:as => :text, :as => :autocomplete, :placeholder=>"Type product name",
:input_html => {:class =>"span2", :rows => 6}, wrapper: :inline_label, label:false  %>

If I remove :as => :text, the auto-complete part works but ':rows => 6' part fail.

And if I keep both, I get 6 rows but the auto-complete stops working.

I need this field to have have multiple rows as well as auto-complete. This is a really silly question but I am stuck. Please help.


回答1:


Simple Form doesn't define an autocomplete input. But if you need an autocomplete input and the text type I think you can do:

f.input :product_description ,
:url => autocomplete_product_name_products_path,
:as => :autocomplete,
:placeholder=>"Type product name",
:input_html => {:class =>"span2", :rows => 6, type => :text },
wrapper: :inline_label, label: false


来源:https://stackoverflow.com/questions/20594445/simple-form-input-as-both-text-and-autocomplete

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!