Search code examples
ruby-on-rails-4formtastichtml-safe

Rails 4 Formtastic action label escaping


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!


Solution

  • 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