Search code examples
ruby-on-rails-3jquery-ui-datepickerformtastic

Datepicker ui with formtastic, rails 3.1


I use rails 3.1, formtastic 2.0.2 and datepicker ui

I made datepicker_input.rb:

 class DatepickerInput < Formtastic::Inputs::StringInput
include Formtastic::Inputs::Base

    def input_html_options
        super.merge(:class => "datepicker")
    end 
 end

In application.js I wrote:

 $('input.datepicker').datepicker()

I use it in my form like :as => :datepicker. I see calendar, pick date and everything is fine except for it doesn't fill column in my model. The only thing that I noticed is that when I fill first date and then all the other fields - it works. When date field is the last - it doesn't work. There is no errors, params[:model_name][:date_field] is not empty just nil in place of date that I chose.


Solution

  • Error was in date format - database just couldn't take format that returned datepicker.