1

の通常の方法ではラベルを削除できないようですnested_fields_for。通常の方法はフラグを立てることlabel: falseです。

= bootstrap_nested_form_for @quote, label_errors: true, label_col: "col-sm-2", control_col: "col-sm-6" do |f|
  =f.text_field :quote_number, value: (@quote.quote_number || next_quote_number), prepend: "<i class='fa fa-tag'></i>".html_safe, control_col: "col-md-6", label: false, class: "input-sm"
  =f.collection_select :customer_id, my_customers, :id, :company_name, {control_col: "col-md-7", include_blank: "Select Customer", label: false}, {class: "input-sm"}

  %table.table.table-condensed{style: "margin-bottom:0px;"}
    %tbody#things
      = f.fields_for :things, :wrapper => false, label_errors: true, html: {class: 'form_inline'} do |thing|
        %tr.fields
          %td{style: "width:100px;border-top:none;"}
            = perm.text_field :quote_amount, value: number_with_precision(perm.object.quote_amount, precision: 2), prepend: "<i class='fa fa-dollar'></i>".html_safe, label: false, class: "input-sm", label: false
          %td{style: "border-top:none;"}
            = perm.collection_select :cat_id, my_categories, :id, :name, include_blank: "Select Category", label: false}, {class: "input-sm"}
          %td{style: "text-align: right; padding-top: 10px;border-top:none;"}
            %br/
            = perm.link_to_remove "<i class='fa fa-close'></i>".html_safe, class: "btn btn-danger btn-sm"
  = f.link_to_add "<i class='fa fa-plus'></i> Add Thing".html_safe, :things, "data-target" => "#things", class: "btn btn-success btn-sm"

次に、内部ではfields_for、それも機能していません。ラッパー ( :wrapper => false) を削除したので、テーブル内で機能します。これがjQuery呼び出しであることは知っています。でラベルを変更できますlabel: "My New Label"label: falselabel: ""デフォルトのフィールド名しか生成されません。

ということで、この部分には 2 つの質問があると思いfields_forます。

  1. ラベルを剥がすことはできますか?
  2. パーシャルを変更するにはどうすればよいですか? (変更できることはわかりましたが、コードの使用例が見つかりません)。
4

1 に答える 1