I have multiple date fields on a node form for which I am using the select widget. The year select list has a range of years that is far too wide for our purposes (1900-present), so we want to limit it. I am able to accomplish this with hook_form_alter, however the fields that are multi-value to not reflect this change when they are loaded with ajax. Here is my current code which gets the first deltas:
public function alterQuarterlyReportForm(&$form, FormState $form_state, $form_id) {
// form_alter functionality for quarterly reports
if ($form_id == 'node_quarterly_report_form' || $form_id == 'node_quarterly_report_edit_form') {
// Limiting range of years in date fields on report form
$form['field_draft_evaluation_date']['widget'][0]['value']['#date_year_range'] = '-3:+3';
$form['field_draft_protocol_date']['widget'][0]['value']['#date_year_range'] = '-3:+3';
$form['field_updated_milestone_plandate']['widget'][0]['value']['#date_year_range'] = '-3:+3';
$form['field_committee_date']['widget'][0]['value']['#date_year_range'] = '-3:+3';
$form['field_liaison_meeting_dates']['widget'][0]['value']['#date_year_range'] = '-3:+3';
$form['field_meeting_date']['widget'][0]['value']['#date_year_range'] = '-3:+3'; }}
Obviously these are each set for delta 0, and what I am having trouble figuring out is how to get this working for each additional value that a user wants to enter. I have attempted a few foreach() loops, but I am not getting it right.