Reputation: 1188
I have a submit button on a form that is an image, and I want it to clear the form once it is clicked.
To make the submit button an image, I use the following code:
<%= f.submit "2", :type => :image, :src => "/assets/down.png" %>
To make the button clear the form, I use the following code
<%= f.submit "2", :type => :reset %>
But I have tried and failed to add two "types" to the form
Any Ideas?
Upvotes: 0
Views: 182
Reputation: 26193
This isn't possible.
By default, the form_for
submit
must and will be an HTML tag <input type="submit" />
. Without the type
attribute being set to "submit"
, the tag wouldn't actually be a submit button and would certainly not be able to submit the form without some sort of client-side intercession (e.g., Javascript).
CORRECTION:
The OP is correct that "image"
is indeed a valid type
attribute for an image button.
Upvotes: 1
Reputation: 1274
You should use javascript here (to submit your form after pressing on your image (or as you want -- reset it).
$('#form').trigger("reset");
Upvotes: 1