June 4, 2015

Symfony dynamic Entity selection in FormType

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



2 thoughts on “Symfony dynamic Entity selection in FormType

    1. 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 *