Arun Kumar Mohan
Arun Kumar Mohan

Reputation: 11915

Rails - Using Font Awesome

How can I include a fontawesome icon within my button?

<%= f.submit 'Post', class: 'btn btn-primary btn-large' %>

I tried

<%= f.submit '<i class="icon-ok icon-white"></i>Post'.html_safe, class: 'btn btn-primary btn-large' %>

But it doesn't display the icon properly. Any help would be appreciated.

Upvotes: 2

Views: 348

Answers (1)

Jon
Jon

Reputation: 10918

If you're using Rails 4 or newer, you can pass a block to the submit method and include your HTML in there.

Try this:

<%= f.submit class: 'btn btn-primary btn-large' do %>
  <i class="icon-ok icon-white"></i> Post ...
<% end %>

See this GitHub issue for more details: https://github.com/plataformatec/simple_form/issues/745

Upvotes: 5

Related Questions