简体   繁体   中英

Rails 4 Autocomplete with Simple Form - class parameter ignored

I am using Simple Form, along with the Rails Autocomplete gem.

I have a straightforward form control, where the autocomplete is working as intended:

<%= f.input :practice, as: :autocomplete, url: autocomplete_practice_name_shifts_path, id_element: '#shift_practice_id', class: 'form-control'  %>

This works perfectly, except that the class: 'form-control' parameter is not being translated onto the form.

If I remove the autocomplete parameters like so:

<%= f.input :practice, id_element: '#shift_practice_id', class: 'form-control'  %>

The class carries through correctly; as such, it seems to be the autocomplete option that is overriding the class.

Can anybody advise what the correct way to set the class on this input is?

好吧,像这样传递它:

input_html: { class: 'form-control' }

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM