diff --git a/core/modules/field_ui/src/Form/FieldStorageAddForm.php b/core/modules/field_ui/src/Form/FieldStorageAddForm.php index 7c54ca94cc..899eca9ed5 100644 --- a/core/modules/field_ui/src/Form/FieldStorageAddForm.php +++ b/core/modules/field_ui/src/Form/FieldStorageAddForm.php @@ -192,7 +192,7 @@ public function buildForm(array $form, FormStateInterface $form_state, $entity_t '#description' => $this->t('A unique machine-readable name containing letters, numbers, and underscores.'), // Calculate characters depending on the length of the field prefix // setting. Maximum length is 32. - '#maxlength' => FieldStorageConfig::NAME_MAX_LENGTH - strlen($field_prefix), + '#maxlength' => FieldStorageConfig::NAME_MAX_LENGTH - ($field_prefix ? strlen($field_prefix) : 0), '#machine_name' => [ 'source' => ['new_storage_wrapper', 'label'], 'exists' => [$this, 'fieldNameExists'],