Rather than
<input type="submit" />
I want to output
<button>
using the button_to method (rails 3.0.0)
Is this possible?
input suggests that the control is editable, or can be edited by the user; button is far more explicit in terms of the purpose it serves. Easier to style in CSS; as mentioned above, FIrefox and IE have quirks in which input[type="submit"] do not display correctly in some cases.
submit : The button submits the form data to the server. This is the default if the attribute is not specified for buttons associated with a <form> , or if the attribute is an empty or invalid value. reset : The button resets all the controls to their initial values, like <input type="reset">.
You use css and style a link <a> to look like a button.
As of the latest version of Rails (4.0.2, not sure about previous versions) passing a block to button_to invokes branch logic in the helper that creates a button element instead of an input.
For example, if you wanted to make a 'delete' button element in haml, bootstrap & fontawesome (my use case):
= button_to(foo_path(@foo),
class: 'btn btn-sm', method: :delete, remote: true) do
<i class="fa fa-times"></i>
If you want them to just always be button elements no matter what, you could always have your button content inside a block instead of the first argument. Not sure what the trade-off is there.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With