$form_state->
setError($element,
t('The %field date is incomplete.',
['%field' =>
$title]));
$form_state->
setError($element[$value],
t('A value must be selected for %part.',
['%part' =>
$value]));
} } else { // If the input is valid, set it.
$date =
$input['object'
];
if ($date instanceof DrupalDateTime && !
$date->
hasErrors()) { $form_state->
setValueForElement($element,
$date);
} // If the input is invalid and an error doesn't exist, set one.
elseif ($form_state->
getError($element) === NULL
) { $form_state->
setError($element,
t('The %field date is invalid.',
['%field' =>
$title]));
} } } } /**
* Checks the input array for empty values.
*
* Input array keys are checked against values in the parts array. Elements
* not in the parts array are ignored. Returns an array representing elements
* from the input array that have no value. If no empty values are found,
* returned array is empty.
*
* @param array $input
* Array of individual inputs to check for value.
* @param array $parts
* Array to check input against, ignoring elements not in this array.
*
* @return array
* Array of keys from the input array that have no value, may be empty.
*/