public function getConstraintsType(BuilderInterface $builder, Field $entity, $data) { $type = $this->get('form.factory')->createNamedBuilder(sprintf("constraints-%d", $entity->getId()), Type\FormType::class, $data, ['translation_domain' => 'geny']); foreach ($builder->supportsConstraints($entity) as $constraintClass) { $constraint = $this->getCachedObject($constraintClass); $constraint->build($type, $entity, $data); } return $type->getForm(); }