Service
form.context by default a Symfony\Component\Form\FormContext . Here is the full definition of this service:
<service id="form.context" class="%form.context.class%"> <argument type="collection"> <argument key="validator" type="service" id="validator" /> <argument key="validation_groups">%form.validation_groups%</argument> <argument key="field_factory" type="service" id="form.field_factory" /> <argument key="csrf_protection">%form.csrf_protection.enabled%</argument> <argument key="csrf_field_name">%form.csrf_protection.field_name%</argument> <argument key="csrf_provider" type="service" id="form.csrf_provider" /> </argument> </service>
In fact, this is a very simple object that simply prepares some basic options used by almost every form, i.e. validator, CSRF protection and factory field.
In fact, the code you posted is equivalent to:
$form = new \Symfony\Components\Form\Form(null, array( 'validator' => $this->get('validator'), 'validation_groups' => ... ... ));
source share