Where this date picker is included from?

11 views
Skip to first unread message

Padmahas Bn

unread,
Jul 17, 2016, 11:40:25 AM7/17/16
to Ruby on Rails: Talk
Here, you can see the date picker. but the code I used is very basic

<div class="field">
<%= label_tag("To date") %>
<%= date_field_tag 'tdate', '2015/08/01', class: 'form-control' %>
</div>

I didn't worried about it until I tried to set default value and you can see the default value '2015/08/01' is not appearing in the date field.
It can't be included from JQuery because I removed "//= require jquery" and "//= require jquery_ujs" from "application.js" and still its showing up.  Nothing special appears in Gemfile too.

ruby version: 2.2.4p230 (2015-12-16 revision 53155) [x86_64-linux]
Rails version: 4.2.6

I still don't care if someone know how to force default value to show up.

Thank you.

Walter Lee Davis

unread,
Jul 17, 2016, 11:49:33 AM7/17/16
to rubyonra...@googlegroups.com
Depending on your browser, a normal HTML5 `<input type="date">` (which is what the ERB above creates) will generate a fancy picker, or it may produce a thing that looks like a text field, but behaves differently from one. Regardless how it appears, a "date" input will only accept ISO-formatted dates as its value. Change your value= to '2015-08-01' and it may appear as you expect.

Walter
> --
> You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group.
> To unsubscribe from this group and stop receiving emails from it, send an email to rubyonrails-ta...@googlegroups.com.
> To post to this group, send email to rubyonra...@googlegroups.com.
> To view this discussion on the web visit https://groups.google.com/d/msgid/rubyonrails-talk/2e3e75b7-bb92-453a-ac2f-82ea5c079129%40googlegroups.com.
> For more options, visit https://groups.google.com/d/optout.

Padmahasa B N

unread,
Jul 17, 2016, 12:00:40 PM7/17/16
to rubyonra...@googlegroups.com
> Change your value= to '2015-08-01' and
> it may appear as you expect.

Yeah you are right Walter. Its appearing now.

Thank you again.

--
Posted via http://www.ruby-forum.com/.
Reply all
Reply to author
Forward
0 new messages