Every field in a form in Symfony is an instance of the parent form. To add a custom error to the form, you must access the form object of the field then add an error into it. Here is how you can embed a custom error to a form field:
$error = new formerror("There is an error with the field"); $form->get('field')->addError($error); // You will also need to include the formerror class at the top of your file: use Symfony\Component\Form\FormError