form-types-validation

Installation
SKILL.md

Form Types Validation (Symfony)

Use when

  • Building or changing a Symfony form type.
  • Adding validation constraints on an entity, a DTO, or a form field.
  • Different rules per context (registration vs profile) through validation groups.
  • Converting values with a data transformer or reacting with form events.
  • Writing a custom constraint, or a form spread across several steps.

Default workflow

  1. Put business constraints on the entity or DTO; keep form-level constraints for UI-only rules such as uploads.
  2. Build the form type with explicit field types and options.
  3. Split rules into validation groups when contexts differ.
  4. Add data transformers or PRE_SET_DATA/PRE_SUBMIT listeners only where the model and the view disagree.
  5. In the controller, check isSubmitted() && isValid() and pass the form itself to render().
Installs
69
GitHub Stars
224
First Seen
Sep 18, 2026