Using awesome font with formtastic submit button

I have a submit button in my form:

= semantic_form_for record do |form|
  = form.actions do
    = form.submit 'Save'

I want to add an icon from FontAwesome, link_toI can use the block:

= link_to record do
  = fa_icon 'save'
  Save

But this does not work with Formtastic form.submit.

I also tried:

= form.submit fa_icon('save')
= form.submit fa_icon('save').html_safe

But both renderings avoid HTML.

How to add a font-awesome badge to a tag <button>?

+4
source share
1 answer

Try using captureto set a label, for example:

- label = capture do
  = fa_icon 'save'
  Save
= form.button label

This seems to work only for form.button, but not for form.submit.. You will need to use form.button label, type: :submit.

+3
source

Source: https://habr.com/ru/post/1546362/


All Articles