I'm trying to install the jQuery UI datepicker with Formtastic. I followed http://blog.brzezinka.eu/webmaster-tips/ruby/ruby-on-rails-formtastic-jquery-ui-datepicker so I:
I keep getting 'Formtastic::UnknownInputError' on <%= f.input :dtstart, :as => :datepicker %>. I googled and searched for this error but can't find a clue in which direction to look. Anybody here an idea? I'm on rails 3.0.3
if you're using :as => :datepicker
, you have to create a custom input for it.
As the documentation suggests, create a new file in app/inputs
named date_picker_input.rb
class DatePickerInput < Formtastic::Inputs::StringInput
def input_html_options
super.merge(:class => "datePicker")
end
end
All you have to do is trigger the JQuery UI addon in your application.js
:
$('.datePicker').datepicker();
If you don't want to bother creating a custom input, you can just add the class directly as in:
<%= f.input :date, :input_html => { :class => 'datePicker'} %>