送信ボタンの simple_form_for が素晴らしい
概要
私の目標は、simple_form_for を使用して送信ボタン内に Fontwesome アイコンを追加することです。
最終目標
今のフォームは次のようなものです:
<%= 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 %>
そして形式は次のとおりです。
現在のフォーム
を追加することは可能ですか? そのボタンの中にはsimple_formが含まれていますか?
解決策
私が見つけた唯一の方法は、純粋な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 %>
そしてそれは期待どおりに機能します:)