我有一個帶有輸入字段和下拉框的表單,其中包含來自其他表的數據。 (連接) 但現在,當我提出這是件好事,但是當我想編輯的字段下拉字段爲空,但文本字段不單擊編輯後,Rails 3.2沒有在表單中保存下拉選擇
我的表單代碼:
<%= form_for @contracten, :html => { :multipart => true } do |f| %>
<% if @contracten.errors.any? %>
<div id="error_explanation">
<h2><%= pluralize(@contracten.errors.count, "error") %> prohibited this contracten from being saved:</h2>
<ul>
<% @contracten.errors.full_messages.each do |msg| %>
<li><%= msg %></li>
<% end %>
</ul>
</div>
<% end %>
<div id="forms">
<div class="field">
<%= f.label :naam %><br />
<%= f.text_field :naam %>
</div>
<br>
<div class="field">
<%= f.label :omschrijving %><br />
<%= f.text_area :omschrijving %>
</div>
<br>
<div class="field">
<%= f.label :organisatie %><br />
<%= f.select :organisatieid, options_for_select(@organisaties.map{ |f| [f.naam, f.id] }), :include_blank => true %>
</div>
<br>
<div class="field">
<%= f.label :vestiging %><br />
<%= f.select :vestigingid, options_for_select(@vestigingens.map{ |f| [f.naam, f.id] }), :include_blank => true %>
</div>
<br>
<div class="field">
<%= f.label :Beheerder %><br />
<%= f.select :persoonid, options_for_select(@personen.map{ |f| [f.naam, f.id] }), :include_blank => true %>
</div>
<br>
<div class="field">
<%= f.label :contractsoort %><br />
<%= f.select :contractsoortid, options_for_select(@contractsoorten.map{ |f| [f.naam, f.id] }), :include_blank => true %>
</div>
<br>
<div class="field">
<%= f.label :datumingang %><br />
<%= f.datetime_select :datumingang %>
</div>
<br>
<div class="field">
<%= f.label :datumeinde %><br />
<%= f.datetime_select :datumeinde %>
</div>
<br>
<div class="field">
<%= f.label :contractduur %><br />
<%= f.number_field :contractduur, :placeholder => 'in jaren' %>
</div>
<br>
<div class="field">
<%= f.label :opzegtermijn %><br />
<%= f.number_field :opzegtermijn, :placeholder => 'In Maanden' %>
</div>
<br>
<div class="field">
<%= f.label :betalingsperiode_eenheid_id %><br>
<%= f.select :betalingsperiodeeenheidid, options_for_select(@betalingsperiodeeenhedens.map{ |f| [f.omschrijving, f.id] }), :include_blank => true %>
</div>
<br>
<div class="field">
<%= f.label :betalingstermijn %><br />
<%= f.number_field :betalingstermijn %>
</div>
<br>
<div class="field">
<%= f.label :pdf %><br />
<%= f.file_field :pdf %>
</div>
<br>
<div class="actions">
<%= f.submit "Toevoegen", :class => 'button3' %>
</div>
</div>
<% end %>
<br>
截圖:
我希望有人知道是什麼問題。
請包括表單的代碼。此外,請確保表單域中的名稱匹配列名... – gabrielhilal 2012-07-12 11:42:27
editted我的問題與_form.html.erb對不起,我忘了:) – 2012-07-12 11:51:32
你有organisatieid,organisatieid,persoonid,contractsoortid數據庫中的同名嗎? – 2012-07-12 11:59:46