Reputation: 161
So my button_to erb tag gives me something similar what is below and I was wondering if it was possible to add an id to the div by passing something along in the options hash rather than using js or adding html manually:
<div>
<input id="button" type="submit" value="title">
<input name="auth_token">
</div>
My button erb code is just
<%= button_to title, {}, :id => "button"%>
Upvotes: 7
Views: 7004
Reputation: 313
As of 3.2, button_to accepts a hash of form attributes via the html_options key "form"
<%= button_to title, {}, :form => { :id => "button" } %>
Upvotes: 13
Reputation: 584
You can't really change the id of the parent div as far as I know.
The button_to options don't really allow for that as you can see.
You can add a class to the parent form though. Not entirely certain why the div is added in with the button with the button_to command to be honest.
Upvotes: 0