- 🇨🇭Switzerland berdir Switzerland
+++ b/src/Form/ReplicateConfirmForm.php @@ -39,6 +46,13 @@ public function buildForm(array $form, FormStateInterface $form_state, RouteMatc + $entityLabelKey = $entity->getEntityType()->getKey('label'); + $entityFieldsDefinitions = $this->entityFieldManager->getBaseFieldDefinitions($entity->getEntityType()->id()); + $labelMaxLength = 128; + if ($entityFieldsDefinitions[$entityLabelKey] instanceof BaseFieldDefinition) { + $labelMaxLength = $entityFieldsDefinitions[$entityLabelKey]->getSetting('max_length'); + }
You have the entity, you can get the field definition from it. This can be simplified to $entity->getFieldDefinition($label_key). no entity field manager necessary.
The code also needs to be moved inside the existing hasKey() check, some entity types don't have a label key.
- 🇨🇭Switzerland berdir Switzerland
Forgot that #3106142: Allow long texts as new labels → changed the default to 255, needs to be rerolled. Could indeed cause a problem if a label is entered that's too long.