Reputation: 61
my controller uses code like this:
if params[:commit] == "Submit"
this used to work fine when I just had buttons. however, now I am using images as buttons like below:
<%= image_submit_tag 'butons/Add-08.png', :class => 'image-button-submit' %>
How can I pass the commit
variable with value Submit
along with this image_submit_tag
?
Upvotes: 2
Views: 520
Reputation: 138
KandadaBoggu is right, but that will (in most browsers) give you a params['commit.x']
and params['commit.y']
rather than just params['commit']
.
If there's only the one button on the form (and you're posting to the same action that renders the form) you can do if request.post?
instead, but that's only going to work if there's just one button, ie: only submit, not submit and cancel.
Upvotes: 2
Reputation: 64363
As per the image_submit_tag documentation you can pass any HTML options. I haven't tested this but the following code should work.
<%= image_submit_tag 'butons/Add-08.png', :name =>"commit", :value =>"Submit" %>
Upvotes: 1
Reputation: 76
I would try passing it as a hidden field inside of the form you're submitting.
hidden_field_tag "commit", "Submit"
Upvotes: 0