Symfony is fantastic for building very quick snappy applications; especially CRUD apps. However, sometimes we want to quickly alter the default CRUD forms with some business logic. For example, if we have Products and Categories and want to be able to create new product entities with a specified category but somehow restrict which categories are accessible in the product form.

Altering the FormType Class

Define the Form as a Service

Usage in a Controller


Categories: Random


Oleg · September 22, 2016 at 3:53 am

it not work for Symfony3, because $this->createForm expected the first argument of type “string” only.

    Jake Litwicki · September 26, 2016 at 6:47 pm

    That’s correct, I’ll write a modification for Symfony3. You’d want to instead call the class of the form Path\To\Form\FormType

Leave a Reply

Your email address will not be published. Required fields are marked *