Sasha
Sasha

Reputation: 3281

rails, adding an undefined attribute to form_tag

i was wondering how do you put a "data-provide" attribute inside a rails form_tag? the html output i would like is...

<input type="text" data-provide="typeahead">

however in a form_tag, i can't just do something like

<%= f.text_field :data-provide => "typehead" %>

how can i add an undefined attribute like that in a form tag? do i need to submit a hidden field or use another helper method? i was looking through the form_tag helper api and it doesn't seem like i can just define another attribute.

it seems like there an easy solution to this, but im not quite sure. help would be appreciated. thanks

Upvotes: 2

Views: 3055

Answers (1)

jdoe
jdoe

Reputation: 15771

Use :data option with a hash:

<%= f.text_field :some_field, :data => {:provide => "typeahead"} %>

Upvotes: 10

Related Questions