@@ -129,15 +129,20 @@ Finally, make this work by adding the location form to your two original forms::
129129 namespace App\Form\Type;
130130
131131 use App\Entity\Company;
132+ use Symfony\Component\Form\AbstractType;
133+
132134 // ...
133135
134- public function buildForm(FormBuilderInterface $builder, array $options): void
136+ class CompanyType extends AbstractType
135137 {
136- // ...
138+ public function buildForm(FormBuilderInterface $builder, array $options): void
139+ {
140+ // ...
137141
138- $builder->add('foo', LocationType::class, [
139- 'data_class' => Company::class,
140- ]);
142+ $builder->add('foo', LocationType::class, [
143+ 'data_class' => Company::class,
144+ ]);
145+ }
141146 }
142147
143148.. code-block :: php
@@ -146,15 +151,18 @@ Finally, make this work by adding the location form to your two original forms::
146151 namespace App\Form\Type;
147152
148153 use App\Entity\Customer;
149- // ...
154+ use Symfony\Component\Form\AbstractType;
150155
151- public function buildForm(FormBuilderInterface $builder, array $options): void
156+ class CustomerType extends AbstractType
152157 {
153- // ...
158+ public function buildForm(FormBuilderInterface $builder, array $options): void
159+ {
160+ // ...
154161
155- $builder->add('bar', LocationType::class, [
156- 'data_class' => Customer::class,
157- ]);
162+ $builder->add('bar', LocationType::class, [
163+ 'data_class' => Customer::class,
164+ ]);
165+ }
158166 }
159167
160168 That's it! You have extracted duplicated field definitions to a separate
0 commit comments