Mike
Mike

Reputation: 1361

using buttons instead of input type="submit" in rails

I have a form that submits data.

Before I had used the submit_tag however, that converts to <input type="submit"

I wanted the buttons to look prettier so now I've started using <button> <span>login</span></button>

How can I submit the form using button the same way it was submitting with input type=submit ?

Upvotes: 1

Views: 604

Answers (2)

lobati
lobati

Reputation: 10235

You should be able to use button_tag instead. This defaults to type="submit", so should have the same behavior.

Upvotes: 0

John Topley
John Topley

Reputation: 115422

You could add a JavaScript event handler that obtains a reference to the form and submits it when the <button> element is clicked.

Upvotes: 2

Related Questions