I'm new to rails, and just found the simple_form gem. I installed it with bootstrap suport, but now I can't get this code to work the way I want it
<%= f.button :submit, "<i class='icon-ok icon-white'></i> Save", class: "btn btn-primary" %>
I just want to put the icon inside the button, but when I do this, it shows me a button with the text '<i class='icon-ok icon-white'></i> Save'
I also tried to do
<%= f.button :submit, class: "btn btn-primary" do %><i class="icon-ok icon-white"></i> Save<% end %>
But with no success. How can I add some HTML inside the button with simple_form gem?
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
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With