我想在民意调查和两个提交按钮中找到可能答案的表格。第一个传递所有文本字段,第二个传递其中一个字段为nil导致验证错误。这是我的_form.html.haml文件:
= form_for [@poll, @question] do |f|
- if @question.errors.any?
#error_explanation
%h2= "#{pluralize(@question.errors.count, "error")} prohibited this question from being saved:"
%ul
- @question.errors.full_messages.each do |msg|
%li= msg
.field
= f.label :title
= f.text_field :title
%p
= f.label :kind
.radio
-@kind_options.each do |option|
%label
=f.radio_button :kind, option[1]
=option[0]
=f.fields_for :possible_answers do |c|
%p
=c.text_field :title, class: "form-control", placeholder: "Enter a possible answer"
.actions
= f.submit 'Save', class: "btn btn-primary"
- x = f
= x.hidden_field :kind, :value => nil
= x.submit 'Corrupted Sumbit Button', class: "btn btn-primary"
如果我提交x或f似乎没有区别:即使我在单选按钮中选择它并点击f.submit按钮,kind也是空白。如何解决这个问题?