ruby-on-railsrubyformssimple-form-for

Fontawesome with simple_form_for on submit button


My goal is to add a Fontawesome icon inside a submit button using simple_form_for

Final goal

right now the form is like:

            <%= simple_form_for @model, html: {class: "d-flex align-items-end"} do |f| %>
            <%= f.input :model, :as => :hidden, :input_html => { :value => model.id } %>
            <%= f.input :x, label: false, :input_html => { :value => model.x_attr } %>
            <%= f.button :submit, "x", class: "btn btn-secondary" %>
            <% end %>

And form is:

Current form

Is it possible to add a <i class="fas fa-cart-arrow-down"></i> inside that button with simple_form?


Solution

  • Only way i could find is to create the submit button on pure HTML

                <%= simple_form_for @model, html: {class: "d-flex align-items-end"} do |f| %>
                <%= f.input :model :as => :hidden, :input_html => { :value => model.id } %>
                <%= f.input :quantity, label: false, :input_html => { :value => model.x},  wrap_with: { tag: :span} %>
    
                <label>m</label>
                <button type="submit" class="btn btn-success btn-card-index-cart" title="Adicionar ao Carrinho">
                    <i class="fas fa-cart-arrow-down"></i>
                </button>
    
                <% end %>
    

    And it works as expected :)