We're using Drupal 9's core Date Range module and need to limit the end date selection to no more than 90 days from today.
I've searched far and wide and have not come up with a workable solution. Seems like it should be simple but I'm stumped.
Drupal Answers is a question and answer site for Drupal developers and administrators. It only takes a minute to sign up.
Sign up to join this communityWe're using Drupal 9's core Date Range module and need to limit the end date selection to no more than 90 days from today.
I've searched far and wide and have not come up with a workable solution. Seems like it should be simple but I'm stumped.
Solved it with hook_form_alter():
$limit = date("Y-m-d", strtotime("+" . 90 . " day"));
$form['field_job_posting_date']['widget'][0]['end_value']['#attributes']['max'] = $limit;