Ruby on Rails Friday, September 30, 2011

Hi Tom,

I had a similar task lately and the solution goes roughly like this:

First you get the localization file from here:
http://jquery-ui.googlecode.com/svn/trunk/ui/i18n/

You need to load this together with the other jQuery js like this:
<%= javascript_include_tag 'jquery/jquery.ui.datepicker-de.js' %>

After that you can setup you form like this:
<%= label :start_date, "Datum von:" %>
<%= text_field_tag :start_date, Time.now.strftime('%d.%m.
%Y'), :autocomplete => "off", :class => "input_element" %>
<%= label :end_date, "bis:" %>
<%= text_field_tag :end_date, Time.now.strftime('%d.%m.
%Y'), :autocomplete => "off", :class => "input_element" %>
<%= submit_tag :for, :value => t("buttons.search") %>

<script>
$.datepicker.setDefaults( $.datepicker.regional["de"] );
$.datepicker.setDefaults({showWeek: true,
minDate: new Date(2011, 0, 1),
maxDate: "today",
showOtherMonths: true,
selectOtherMonths: true });
$('#start_date').datepicker();
$('

No comments:

Post a Comment