HTML code inside buttons with simple_form HTML code inside buttons with simple_form ruby ruby

HTML code inside buttons with simple_form


Don't use content_tag. The following works:

  <%= button_tag(type: 'submit', class: "btn btn-primary") do %>    <i class="icon-ok icon-white"></i> Save  <% end %>


In simple_form 3.0rc use :button button type (it passes your block to original ActiveView button helper):

<%= f.button :button do %>  <i class="icon-save"></i>  Commit<% end %>

Or write additional button wrapper.

For additional info look into simple_form/form_builder.rb FormBuilder#button method.


I think you can't do it with simple_form. But I have good news for you. You should be fine using rails helper along side with simple form.

just do

button_tag(type: 'submit', class: "btn btn-primary") do  content_tag(:i, class: "icon-ok icon-white")  "Save"end

Not sure if this works, even the syntax but it should give you a hint