diff --git a/core/lib/Drupal/Core/Render/Element/MachineName.php b/core/lib/Drupal/Core/Render/Element/MachineName.php index ade3894..291f2c6 100644 --- a/core/lib/Drupal/Core/Render/Element/MachineName.php +++ b/core/lib/Drupal/Core/Render/Element/MachineName.php @@ -216,9 +216,16 @@ public static function validateMachineName(&$element, FormStateInterface $form_s // Verify that the machine name is unique. if ($element['#default_value'] !== $element['#value']) { - $function = $element['#machine_name']['exists']; - if (call_user_func($function, $element['#value'], $element, $form_state)) { - $form_state->setError($element, t('The machine-readable name is already in use. It must be unique.')); + // @todo maybe #access + if ($element['#disabled']) { + // Do not allow to change value of the disabled element. + $element['#value'] = $element['#default_value']; + } + else { + $function = $element['#machine_name']['exists']; + if (call_user_func($function, $element['#value'], $element, $form_state)) { + $form_state->setError($element, t('The machine-readable name is already in use. It must be unique.')); + } } } }