
Symfony Forms
FormType, form builder, validation, CSRF, file upload, custom form types, data transformers
1Which base class should be extended to create a custom form type in Symfony?
Which base class should be extended to create a custom form type in Symfony?
Answer
AbstractType is the base class that all Symfony form types must extend. It provides the buildForm() method to configure fields and configureOptions() to define form options like data_class. This object-oriented approach allows forms to be reused across multiple controllers.
2Which method should be used in a FormType to add fields to the form?
Which method should be used in a FormType to add fields to the form?
Answer
The buildForm() method receives a FormBuilderInterface that allows adding fields via the add() method. This method is called automatically when the form is created and allows defining all fields with their respective types and options.
3How to handle form submission in a Symfony controller?
How to handle form submission in a Symfony controller?
Answer
The handleRequest() method reads data from the HTTP request and binds it to the form. Then, isSubmitted() checks if the form was submitted and isValid() verifies that data meets validation constraints. This pattern is standard for all Symfony forms.
Which option links a form to an entity class in configureOptions()?
How to retrieve submitted data from a validated form?
+19 interview questions
Other Symfony interview topics
Modern PHP (8.1+)
Symfony Basics
Routing & Controllers
Twig & Templates
Doctrine ORM Basics
Data Validation
Dependency Injection & Services
Security & Authentication
Doctrine Advanced
API Platform
Serializer Component
Events & Event Subscribers
Console & Commands
Messenger Component
HTTP Client
Cache & Performance
Workflow Component
Testing Symfony
Mailer Component
Translations & i18n
EasyAdmin Bundle
Symfony Architecture
Performance & Optimization
Security Advanced
Custom Bundles
Microservices with Symfony
Real-time & WebSockets
Deployment & DevOps
Master Symfony for your next interview
Access all questions, flashcards, technical tests, code review exercises and interview simulators.
Start for free