# Submit\_tag image?

**URL:** <https://www.ruby-forum.com/t/submit-tag-image/70366>\
**Category:** Rails\
**Created:** [September 28, 2006, 6:56pm UTC](https://www.ruby-forum.com/t/submit-tag-image/70366 "2006-09-28T18:56:09Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [September 28, 2006, 6:56pm UTC](https://www.ruby-forum.com/t/submit-tag-image/70366/1 "2006-09-28T18:56:09Z")

</div>

How does one assign an image in place of a simple button in ruby/rails?  
For instance, my submit tag for searching looks like:

\<%= form\_tag :action =\>‘search’, :controller =\> ‘search’ %\>  
\<%= text\_field\_with\_auto\_complete :product, :title %\>  
\<%= submit\_tag “Go” %\>  
\<%= end\_form\_tag %\>

And it works fine but looks a little ugly. I’d like to replace the ‘Go’  
with an image of a magnifying glass or something. What’s the best way  
to do that?

Thanks…

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [September 28, 2006, 7:12pm UTC](https://www.ruby-forum.com/t/submit-tag-image/70366/2 "2006-09-28T19:12:58Z")

</div>

image\_submit\_tag

> **[ActionView::Helpers::FormTagHelper](https://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#M000503)**
>
> Provides a number of methods for creating form tags that don't rely on an Active Record object assigned to the template like FormHelper does. Instead, you provide the names and values manually.

c.

Vince W. wrote:

> How does one assign an image in place of a simple button in ruby/rails?  
> For instance, my submit tag for searching looks like:
> 
> \<%= form\_tag :action =\>‘search’, :controller =\> ‘search’ %\>  
> \<%= text\_field\_with\_auto\_complete :product, :title %\>  
> \<%= submit\_tag “Go” %\>  
> \<%= end\_form\_tag %\>
> 
> And it works fine but looks a little ugly. I’d like to replace the ‘Go’  
> with an image of a magnifying glass or something. What’s the best way  
> to do that?
> 
> Thanks…

---

<div class="post-metadata">

**Author:** ![vince](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/v/b5e925/32.png) [@vince](https://www.ruby-forum.com/u/vince)\
**Post date:** [September 28, 2006, 7:15pm UTC](https://www.ruby-forum.com/t/submit-tag-image/70366/3 "2006-09-28T19:15:02Z")

</div>

you can supply an id to the submit tag and use an image to replace the  
button.

…This would make a great helper if someone wrote a little code to  
automtically add the image as a button if supplied!
