Adding class id to button_to button div

So my button_to erb tag gives me something similar, which is below, and I was wondering if I could add id to the div by passing something in the option hashes instead of using js or adding html manually:

<div> <input id="button" type="submit" value="title"> <input name="auth_token"> </div> 

My erb code is just

 <%= button_to title, {}, :id => "button"%> 
+4
source share
2 answers

You cannot change the id of the parent div as far as I know.

The button_to options really don't allow this as you can see.

However, you can add the class to the parent form. It's not entirely clear why a div is added with a button with a button button_to, to be honest.

0
source

Starting with 3.2, button_ accepts a hash of form attributes via the "html_options" key

 <%= button_to title, {}, :form => { :id => "button" } %> 
+8
source

All Articles