Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Leaving date/time blank in Rails datetime_select

Is there an easy way to have the option to not specify a date or datetime in a Rails form that uses datetime_select, date_select or time_select? By default, the fields are set at the current date/time and there's no way to not choose a date/time.

Using Rails 3.2.8

like image 852
at. Avatar asked Dec 06 '25 01:12

at.


1 Answers

What you want is the include_blank option: (Nil value on datetime_select?)

f.datetime_select :attr_name, include_blank: true
like image 58
MrYoshiji Avatar answered Dec 08 '25 14:12

MrYoshiji



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!