3

Does anyone know how to eliminate the x and y params when you use image_submit_tag with a get method?

I have a simple search form, and using get to pass the value in the url. When I use image_submit_tag, it also appends the x and y coords, so I get urls like

http://example.com?q=somesearchterm&x=15&y=12

When I have used submit_tag, I can use the :name => nil attribute (was in one of Ryan Bates' Railscasts), but it doesn't seem to work for image_submit_tag. Granted it doesn't affect functionality, but I don't need them and would like them quieted.

Alan S
  • 305
  • 1
  • 3
  • 11

1 Answers1

2

That's actually part of HTML and the browser, not Rails. There is not much you can do apart from change your use of the image_submit or intercept the form submission with JS and edit the parameters. You may also be able to use a regular submit and style it using CSS to display an image, or use an image and attach JS to it to submit the form.

Toby Hede
  • 36,755
  • 28
  • 133
  • 162
  • For me, these values are actually getting merged into my parameter list in an unexpected way: image_submit_tag('image file.png', :name => 'filter') This code generates this HTML: Then the controller gets this: {"filter.y"=>"9", "filter.x"=>"9", "controller"=>"reports", "action"=>"index"} I use the name to determine what button was pressed. How are the x and y values getting merged into my name? – jsarma Feb 10 '14 at 18:41