English spoken conference

You are browsing the Symfony 5.0 documentation, which changes significantly from Symfony 3.x. If your app doesn't use Symfony 5.0 yet, browse the Symfony 3.4 documentation.

How to Access Services or Config from Inside a Form

5.0 version

How to Access Services or Config from Inside a FormΒΆ

The content of this article is no longer relevant because in current Symfony versions, form classes are services by default and you can inject services in them using the service autowiring feature.

Read the article about creating custom form types to see an example of how to inject the database service into a form type. In the same article you can also read about configuration options for form types, which is another way of passing services to forms.

This work, including the code samples, is licensed under a Creative Commons BY-SA 3.0 license.