You will also have faced the problem, that some information has a different formatting in different countries. Those date columns are a good example for this. Here is what I usually encouter:
- dd/mm/yyyy
- mm/dd/yyyy
- yyyy/mm/dd
So, what you're going to do to satisfy everyone? Tell them the format, they should you? Try to guess what they mean by looking at the input?
Why not make this really easy (at least) for date input fields? Here is how:
- Get a decent javascript calendar
- Integrate it with ruby on rails
- Make your users happy
Step 1: What is a decent javascript calendar?
Just google for "javascript calendar" and you will find: The coolest DHTML / Javascript calendar
A very nice and sexy javascript based calendar (LGPL).
Step 2: How to integrate this with a rails project?
How about: "script/plugin install http://opensvn.csie.org/calendariffic/calendariffic/"
And you're done?
Step 3: Help your users with your date fields
1. Add the javascript files to your view
<%= javascript_include_tag 'calendariffic/calendar.js', 'calendariffic/calendar-setup.js', 'calendariffic/lang/calendar-en.js' %>
2. Add the css files to your view (there are many precreated layouts available: aqua, winter, blue, sommer, green, win2k-1|2, win2k-cold-1|2, system)
<%= stylesheet_link_tag 'calendariffic/calendar-win2k-cold-1.css' %>
3. Create a (readonly) date field in your view
< % = calendariffic_input(false, 'date_field_name_goes_here', 'calendariffic/date.png', 'start_cal', '%m/%d/%y', date_field_value_or_nil_goes_here, {:class => 'myfavoriteclass', :readonly => 'true'}, {:class => 'borderless'}) %>
Why should the date field be readonly? That's how you "help" your users (and yourself), and tell them that they have to click on the nice little icon to input their date value :)
Caution:
If you use a language different then "../lang/calendar-en.js", you will have to define one javascript variable inside the language javascript file:
Calendar._FD = 1; // First day of the week. "0" means display Sunday first, "1" means display Monday first, etc.
Thanks to the author of calendariffic (Paul Danese), who helped me with the javascript language issue, I was able to add good looking and "user guiding" date fields to my web application within a few minutes.
1 comment:
Hello! Starting to use this plugin...
couple of problems:
In Webrick log i see this error:
ActionController::RoutingError (No route matches "/stylesheets/calendariffic/menuarrow.gif" with {:method=>:get}):
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:104:in `service'
C:/ruby/lib/ruby/1.8/webrick/httpserver.rb:65:in `run'
C:/ruby/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:162:in `start_thread'
C:/ruby/lib/ruby/1.8/webrick/server.rb:95:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `each'
C:/ruby/lib/ruby/1.8/webrick/server.rb:92:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:23:in `start'
C:/ruby/lib/ruby/1.8/webrick/server.rb:82:in `start'
And the main problem : only one date select on page works!!! How to make it possible to select several dates?
Thanx!
Post a Comment