Rails在视图中复制相同形式的字段为空

时间:2015-08-14 05:27:28

标签: ruby-on-rails

我有一个与一个模型关联的视图,但是在jquery函数显示它们之前,隐藏了相同形式的多个版本。当我尝试提交一个时,所有字段都是空的。

以下是有问题的观点:

= form_for @rfi do |f|
    - if @rfi.errors.any?
      #error_explanation
        h2 = "#{pluralize(@rfi.errors.count, "error")} prohibited this rfi from being saved:"
        ul
          - @rfi.errors.full_messages.each do |message|
            li = message

    .field
      = f.label :svg_ref, "SVG PO Number"
      = f.text_field :svg_ref

    .field
      = f.label :vendor_ref, "Vendor SO Number"
      = f.text_field :vendor_ref

    .field
      = f.label :due
      = f.text_field :due
      = f.hidden_field :rfi_type, value:"order"
    .actions 
      = f.submit



.rfi_type.rfi_type_quote
  = form_for @rfi do |f|
    - if @rfi.errors.any?
      #error_explanation
        h2 = "#{pluralize(@rfi.errors.count, "error")} prohibited this rfi from being saved:"
        ul
          - @rfi.errors.full_messages.each do |message|
            li = message

    .field
      = f.label :reference, "Quote number"
      = f.text_field :reference
      = f.hidden_field :rfi_type, value:"quote"
    .field
      = f.label :due
      = f.text_field :due
    .actions 
      = f.submit

这是涉及的Jquery

$ ->
    $(".rfi_type").hide()
    $(".rfi_type_order").show()


    $("input:radio[name=rfi_type]").change ->
        $(".rfi_type").hide()
        $(".rfi_type_"+$(this).val()).show()
        return
    return

0 个答案:

没有答案