mardi 21 avril 2015

datepicker not sending value with rest of form

I used to use the 'ui_datepicker-rails3' gem to deal with my date pickers but have subsequently retired it with the view to moving things to rails 4 eventually. In addition to figuring out that 'jquery-ui-rails', '>=5.0' deals with date pickers quite nicely.

  = simple_form_for job, :url => job_path(job), :html => { :method => :put } do |f|
    = f.input :booked_date, :label => "Reschedule for", :as => :datepicker
    = f.input :job_card_id, :label => "or add to", :hint => "Job Card for today", :as => :select, :collection => @job_cards, label_method: :franchisee_name, value_method: :id, include_blank: true
    = f.input :last_message, :label => "Reason for reschedule"
.actions  
      = f.submit "Reschedule", :class => "btn btn-primary"
      = link_to "Do not reschedule", job_path(job), :class => "btn btn-secondary"

This is a simple form and the layout, date picker and everything works exactly as it did before.

With one exception

The dates that are picked are not making it in to the submitted forms' values

Processing by JobsController#update as HTML
  Parameters: {"utf8"=>"✓", "authenticity_token"=>"x+8Lw1NMmYIIySUcp9JeTDXzGnHYqL6hCWkof6nK/0Y=", "job"=>{"booked_date"=>"", "job_card_id"=>"", "last_message"=>"jh"}, "commit"=>"Reschedule", "id"=>"1001787"}

If I change the field type to :as => text and type the date in, it's fine. It I comment out the field type (so it defaults to the 3 select date combo) it also works.

coffee script for completion

$ ->
  $("#job_booked_date").datepicker({
    dateFormat: "dd MM yy",
    minDate: 0
      });

What gives? The values seem to be in there when I date pick them, but it's not being sent in the form submission.

Aucun commentaire:

Enregistrer un commentaire