symfony - What is Form Context in Symfony2 -
i getting started symfony2 , trying understand form component. looking @ page http://docs.symfony-reloaded.org/guides/forms/overview.html
and can understand how create form classes confusing how use forms in our controller.
$form = contactform::create($this->get('form.context'));
does have more in depth explanation of form.context portion of code, , actual process behind using forms within controllers?
thanks.
form.context
service symfony\component\form\formcontext
object default. here's full definition of 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>
actually it's simple object prepare basic options used every form, ie. validator, csrf protection , field factory.
in fact code you've posted equivalent of:
$form = new \symfony\components\form\form(null, array( 'validator' => $this->get('validator'), 'validation_groups' => ... ... ));
Comments
Post a Comment