// A button's #value does not require validation, so for convenience we
// allow the value of the clicked button to be retained in its normal
// $form_state->getValues() locations, even if these locations are not
// included in #limit_validation_errors.
if (!
empty($triggering_element['#is_button'
])) { $button_value =
$triggering_element['#value'
];
// Like all input controls, the button value may be in the location
// dictated by #parents. If it is, copy it to $values, but do not
// override what may already be in $values.
$parents =
$triggering_element['#parents'
];
if (!NestedArray::
keyExists($values,
$parents) && NestedArray::
getValue($form_state->
getValues(),
$parents) ===
$button_value) { NestedArray::
setValue($values,
$parents,
$button_value);
} // Additionally, self::doBuildForm() places the button value in
// $form_state->getValue(BUTTON_NAME). If it's still there, after
// validation handlers have run, copy it to $values, but do not override
// what may already be in $values.
$name =
$triggering_element['#name'
];
if (!
isset($values[$name]) &&
$form_state->
getValue($name) ===
$button_value) { $values[$name] =
$button_value;
} }