0

I've been toying with using icons instead of standard buttons. I like the look of it and occasionally a icon is clearer than a labelled button.

While I found it easy to implement for link_to calls;

<%= link_to raw('<i class="icon-exclamation-sign"></i>'), '#' %>

I am struggling to achieve the same result when nested with form_for (or simple_form_for). Is there a way to use an icon for a submit or input when working with the form?

Here are some example forms from my code using the standard buttons:

<%= simple_form_for :present, url: present_path(list_item), method: 'put' do |f| %>
    <%= f.hidden_field :purchased, value: "1" %>
    <%= f.submit "owned" %>
<% end %>

<%= form_for :present, action: 'new', url: presents_path do |f| %>
    <%= f.hidden_field :purchased, value: '0' %>
    <%= f.submit "List", class: "btn btn-mini" %>
<% end %>

I've tried a few methods but none of yielded just the icon acting as a button - most render the button with either the raw HTML as its contents or the icon within the button.

The end result I'd like to be able to implement is just the icon acting as a click-able item (similar to the link_to result).

SinFulNard
  • 173
  • 2
  • 2
  • 10

1 Answers1

0

you probably want to look at image_submit_tag http://api.rubyonrails.org/classes/ActionView/Helpers/FormTagHelper.html#method-i-image_submit_tag

jvnill
  • 29,479
  • 4
  • 83
  • 86
  • I'll give this a bash - I'm not sure it will blend with use of glyphicons, which I reference using an tag () as opposed to them being a basic image file per icon. – SinFulNard Feb 19 '13 at 03:44