加入第二嵌套形式的新字段,第一嵌套表單字段disappers我有三個表軌道而在編輯
1)客戶端 2)家族 3)emplyoee
同時加入在新形式寄託都新字段完美的作品
但在編輯形式,如果我添加嵌套屬性爲家庭第一 然後我增加對員工的嵌套屬性,那麼字段中添加家庭都不見了和字段添加員工
class Client < ActiveRecord::Base
self.primary_key = "id"
has_many :familys , dependent: :destroy, :foreign_key => 'client_id'
accepts_nested_attributes_for :familys , allow_destroy: true
has_many :employees , dependent: :destroy, :foreign_key => 'client_id'
accepts_nested_attributes_for :employees , allow_destroy: true
end
class Family < ActiveRecord::Base
belongs_to :client
end
class Employee < ActiveRecord::Base
belongs_to :client
end
#-------_form.html.erb-----------------------------#
<%= nested_form_for(@client) do |f| %>
<div><%= f.submit 'addfamily',:name => "add_n_tenpo" %></div>
<%= f.fields_for :familys do |w| %>
<tr>
<td class="label_width">巡店店舗</td>
<td><%= w.text_field :tenpo_code_1, class: 'form-control tenpoautofill' %></td>
<td><%= w.text_field :tenpo_code_2, class: 'form-control tenpoautofill' %></td>
</tr>
<% end %>
<div><%= f.submit 'addemployee',:name => "add_nw_tenpo" %></div>
<%= f.fields_for :employees do |nw| %>
<tr>
<td class="label_width">巡店店舗</td>
<td><%= nw.text_field :nw_tenpo_code_1, class: 'form-control' %></td>
<td><%= nw.text_field :nw_tenpo_code_2, class: 'form-control' %></td>
</tr>
<% end %>
<% end %>
你可以張貼形式的代碼? –
我已編輯的代碼 –