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...

有帮助吗?

解决方案

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.

其他提示

for rails 4.2+ and 'simple_form (~> 3.1.0) what worked for me was changing

<%= f.button :submit, class: 'btn btn-success' %>

to

<%= f.button :button, class: 'btn btn-success' do %>
        <span class="glyphicon glyphicon-ok" aria-hidden="true></span> Update Form
    <% end %>

by changing

  1. the :submit to a :button
  2. adding a span to introduction the glyphicon
  3. add the text label, which was auto generated but now I need to supply it if I want any text
许可以下: CC-BY-SA归因
不隶属于 StackOverflow
scroll top