Jak wstrzyknąć pojemnik na FormType w Symfony 3.0?Symfony 3 Inject Container w FormType
Mój plik services.yml:
services:
advertiser.form.report:
class: App\AdvertiserBundle\Form\ReportType
arguments: ["@service_container"]
W regulatorze Działanie:
$report = $this->get('advertiser.form.report');
$form = $this->createForm($report);
mam ten błąd:
Expected argument of type "string", "App\AdvertiserBundle\Form\ReportType" given
Zamień $ raport na "ReportType :: class". Niezbyt intuicyjny, ale w końcu spowoduje wyciągnięcie typu raportu z kontenera. – Cerad
Przy okazji, musisz oznaczyć swoją usługę: http://symfony.com/doc/current/cookbook/form/create_custom_field_type.html#creating-your-field-type-as-a-service – Cerad
To działa doskonale ! Dzięki – Siol