diff --git a/core/lib/Drupal/Core/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php index 1c8b23b48a..762509f6d4 100644 --- a/core/lib/Drupal/Core/Render/Element/MachineName.php +++ b/core/lib/Drupal/Core/Render/Element/MachineName.php @@ -28,7 +28,8 @@ * - The form state object. * In most cases, an existing API or menu argument loader function can be * re-used. The callback is only invoked if the submitted value differs from - * the element's #default_value. + * the element's initial #default_value. The initial #default_value is + * stored in form state so AJAX forms can be reliably validated. * - source: (optional) The #array_parents of the form element containing the * human-readable name (i.e., as contained in the $form structure) to use as * source for the machine name. Defaults to array('label'). @@ -260,7 +261,7 @@ public static function validateMachineName(&$element, FormStateInterface $form_s // Verify that the machine name is unique. If the value matches the initial // default value then it does not need to be validated as the machine name - // elements assumes the form is editing the existing value. + // element assumes the form is editing the existing value. $initial_values = $form_state->get('machine_name.initial_values') ?: []; $element_path = implode('][', $element['#parents']); if (!array_key_exists($element_path, $initial_values) || $initial_values[$element_path] !== $element['#value']) {