As a complete answer based on previous answers / comments:
To access the service from your form type, you need to:
1) Define your type of form as a service and enter the necessary service into it:
2) Now in the form type class, enter it in the constructor:
// src/AppBundle/Form/MyFormType.php class MyFormType extends AbstractType { protected $myService; public function __construct(MyServiceClass $myService) { $this->myService = $myService; } public function buildForm(FormBuilderInterface $builder, array $options) { $this->myService->someMethod(); // ... } }
Shindarth
source share