I have a view associated with one model but there are multiple versions of the same form that are hidden until a jquery function shows them. When I try to submit one, all the fields are empty.
Here is the view in question:
= 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
This is the Jquery involved
$ ->
$(".rfi_type").hide()
$(".rfi_type_order").show()
$("input:radio[name=rfi_type]").change ->
$(".rfi_type").hide()
$(".rfi_type_"+$(this).val()).show()
return
return
via Chebli Mohamed
Aucun commentaire:
Enregistrer un commentaire