I have a few forms in my application which where using date_select
and I've just changed to using date_field
(which uses the HTML5 form elements) the only issue I'm having is that date_select
would default to todays date which was perfect for us but date_field
is defaulting to dd/mm/yyyy
instead.
I'm running into issues with people blindly submitting the form and triggering validation errors.
Is it possible to default date_field
to today?
If you installed Rails4 via gem, it has below bug yet.
https://github.com/rails/rails/commits/master/actionview/lib/action_view/helpers/tags/datetime_field.rb
Fix above and you can set default value like this
<%= f.date_field :birthday, :value => Time.now.strftime('%Y-%m-%d') %>
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With