Rails 4 Formtastic action label escaping

156 views Asked by At

Does anyone know how to add a glyphicon to a formtastic submit button label? It seems that no matter what I do, the string is always escaped

The current snippet I have is:

<%= f.action :submit, label: "<span class='glyphicon glyphicon-floppy-disk'></span> Save".html_safe, button_html: { class: 'btn btn-primary' } %>

Thanks!

1

There are 1 answers

0
Dan Klassen On BEST ANSWER

In the end I wound up just using a plain old submit button in the following format:

<%= button_tag(type: 'submit', class: 'btn btn-primary') do %>
    <span class='glyphicon glyphicon-floppy-disk'></span> Save
<% end %>

If anyone else has a better way of accomplishing this I'm all ears