Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
By rameshsomepalli99 on
I created a custom module for form which accepts from date and to date as user input i would like to restrict the user from selecting a date prior to current date. below is my code snippet.
$form['oneway']['from_date'] = array (
'#type' => 'date',
'#title' => t('From Date'),
'#date_year_range' => '-80:0',
'#required' => TRUE,
);
Please help me out ....
Thank & Regards,
Ramesh S
Comments
Drupal 8 or 7 ?
Drupal 8 or 7 ?
Drupal 8
Hi Joshi,
its drupal 8
$form['oneway']['from_date']
Thanks So Much
Hi Joshi,
Thank you so much. Works like a charm.
Thanks & Regards,
Ramesh S
how to restrict 60 days
Hi
its working for me but i want 60 days restrict. Any suggestions please
Hey
Hey
if you want to set previous 60 days then just use
and for next 60 days just replace - with +
e.g
Not working
I used this in D8 but the output is not as expected.