Symfony Forms: Dos and Don'ts
summary
Shows concrete rules: register reusable form types as services (avoid anonymous types), name them with the Type suffix, and keep only presentation logic there; wire options via configureOptions and prefer explicit option defaults so upgrades stay compatible; handle complex conversions with data transformers instead of stuffing logic into controllers; for selects use choice_label, choice_value, property_path and choice_attr to control labels, values and attributes; bind complex submissions to DTOs rather than entities and use the FormBuilder/FormFactory workflow (createBuilder, submit/handleRequest) consistently.
AI-written summary · about
chapters (11)
- 0:00Introduction to Symfony Forms
- 3:55Common form mistakes
- 8:15Dropdown and choice types
- 12:37Form types and services
- 17:18Form builders and prototypes
- 21:01Best practices overview
- 25:54Event handling in forms
- 30:14Validation and constraints
- 35:14Advanced form techniques
- 40:36Real-world form examples
- 45:17Summary and Q&A
