diff -u b/src/Form/FieldConfigCloneForm.php b/src/Form/FieldConfigCloneForm.php --- b/src/Form/FieldConfigCloneForm.php +++ b/src/Form/FieldConfigCloneForm.php @@ -4,6 +4,7 @@ use Drupal\Core\Entity\EntityForm; use Drupal\Core\Entity\EntityTypeBundleInfoInterface; +use Drupal\Core\Entity\EntityTypeInterface; use Drupal\Core\Entity\EntityTypeManagerInterface; use Drupal\Core\Entity\Query\QueryFactory; use Drupal\Core\Form\FormStateInterface; @@ -162,9 +163,15 @@ public function validateForm(array &$form, FormStateInterface $form_state) { parent::validateForm($form, $form_state); - if ($this->isInvalidMachineName($form_state->getValue('target_field_id'), [], $form_state)) { + $target_field_id = $form_state->getValue('target_field_id'); + if ($this->isInvalidMachineName($target_field_id, [], $form_state)) { $form_state->setErrorByName('target_field_id', $this->t('If the current bundle is selected, a different target field must be chosen as there cannot be multiple instances of the same field in the same bundle.')); } + if (strlen($target_field_id) > EntityTypeInterface::ID_MAX_LENGTH) { + $form_state->setErrorByName('target_field_id', $this->t('Field machine names cannot be longer than @max_chars characters.', [ + '@max_chars' => EntityTypeInterface::ID_MAX_LENGTH, + ])); + } } /**