This project is archived and is in readonly mode.
default user input handling for dates could be improved
-
trevor
this is what i'm currently doing to get the dates to save and display correctly without modifying generated scaffolding -
layout
<!DOCTYPE html> <html> <head> <title>Posts: <%= controller.action_name %></title> <%= stylesheet_link_tag 'scaffold' %> <%= stylesheet_link_tag 'jquery/css/smoothness/jquery-ui-1.7.2.custom.css' %> <%= javascript_include_tag :defaults %> <%= javascript_include_tag 'jquery/js/jquery-1.3.2.min.js', 'jquery/js/jquery-ui-1.7.2.custom.min.js' %> <script> var $j = jQuery.noConflict(); $j.datepicker.setDefaults({ dateFormat: 'yy-mm-dd', constrainInput: true, showOn: 'both', buttonImage: '<%= image_path('calendar.gif') %>', buttonImageOnly: true }); </script> <%= csrf_meta_tag %> </head> <body> <p class="notice"><%= notice %></p> <%= yield %> </body> </html>form
<% form_for(@post) do |f| %> <%= f.error_messages %> <script> // test for HTML5 input type="date" support var i = document.createElement("input"); i.setAttribute("type", "date"); if (i.type == "text") { // type="date" unsupported $j(function() { $j("#post_my_date").datepicker(); }); } </script> <div class="field"> <%= f.label :my_date %><br /> <%= f.text_field :my_date, :type => "date", :placeholder => "My Date", :value => (f.object.my_date.strftime("%Y-%m-%d") if f.object.my_date) %> </div> <div class="actions"> <%= f.submit %> </div> <% end %> -
Rohit Arondekar
- State changed from new to stale
- Importance changed from to Low
Marking ticket as stale. If this is still an issue please leave a comment with suggested changes, creating a patch with tests, rebasing an existing patch or just confirming the issue on a latest release or master/branches.