Search code examples
ruby-on-railshamlsimple-formglyphicons

How to put a glyphicon in a simple_form submit in Rails?


I wanted to edit my simple_form submit button, replacing the label by a glyphicon but couldn't do it.

Is there a nice way to perform this trick ?

Many thanks !

EDIT:

Haml code with working button :

= link_to [:admin, comment], method: :delete, data:{confirm: "are you sure ?"}, class: "btn btn-sm btn-danger" do
  %i.glyphicon.glyphicon-trash

But it does't work with a submit button...


Solution

  • The good way to do it was to simply put a button input instead of a simple submit one, since a button in a from submits it.

    = f.button :submit do
      %i.glyphicon.glyphicon-user
      Add user
    

    It actually works.

    It seems that simple_form is more strict on the form submit's code structure.