# Overriding html generated for submit\_tag and selected links

**URL:** <https://www.ruby-forum.com/t/overriding-html-generated-for-submit-tag-and-selected-links/165903>\
**Category:** Rails\
**Created:** [April 19, 2009, 3:11pm UTC](https://www.ruby-forum.com/t/overriding-html-generated-for-submit-tag-and-selected-links/165903 "2009-04-19T15:11:09Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [April 19, 2009, 3:11pm UTC](https://www.ruby-forum.com/t/overriding-html-generated-for-submit-tag-and-selected-links/165903/1 "2009-04-19T15:11:09Z")

</div>

Hi,

Probably something simple, but I’m trying to change my submit\_tag and  
other buttons to CSS based buttons based on the article at  
[http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html](http://www.oscaralexander.com/tutorials/how-to-make-sexy-buttons-with-css.html)

Basically this needs the following HTML markup:

Button Text

So, the question is how can I change the generated HTML (or better yet  
create a helper) to allow me to spit this out for form actions and  
some link\_to’s, specifically the inner bit?

Any help would be appreciated as my google-fu has not been strong on  
this one. I’m on rails 2.3.2.

Cheers,

Steve

---

<div class="post-metadata">

**Author:** ![steve](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/s/f19dbf/32.png) [@steve](https://www.ruby-forum.com/u/steve)\
**Post date:** [April 21, 2009, 3:07pm UTC](https://www.ruby-forum.com/t/overriding-html-generated-for-submit-tag-and-selected-links/165903/2 "2009-04-21T15:07:12Z")

</div>

Hi Steve,

Acutally, there are no way to do it for submit\_tag & button\_to, those  
helpers should be totally rewritten to suport the markup you need. But  
if you are building a modern unobtrusive app, then you don’t really  
need the functionality of those helpers, so you can just replace them  
with a custom helper that just generates the markup you need.

And cusomizing the link\_to is quite easy:

def cool\_link\_to(title, url, options = {})  
options[:class] ||= ‘’  
options[:class] += ’ button’  
link\_to(content\_tag(:span, title), url, options)  
end

\<%= cool\_link\_to “Edit”, ‘/edit/123’, :class =\> ‘some-other-class’  
%\>

# =\> [Edit\</](https://www.ruby-forum.com/edit/123)
[](https://www.ruby-forum.com/edit/123)

[span\>](https://www.ruby-forum.com/edit/123)

Dmitry
