File tree Expand file tree Collapse file tree 2 files changed +24
-4
lines changed
src/Symfony/Component/Form
Tests/Extension/Core/Type Expand file tree Collapse file tree 2 files changed +24
-4
lines changed Original file line number Diff line number Diff line change @@ -27,11 +27,15 @@ class CollectionType extends AbstractType
27
27
public function buildForm (FormBuilderInterface $ builder , array $ options )
28
28
{
29
29
if ($ options ['allow_add ' ] && $ options ['prototype ' ]) {
30
- $ prototype = $ builder -> create ( $ options [ ' prototype_name ' ], $ options [ ' entry_type ' ], array_replace (array (
30
+ $ prototypeOptions = array_replace (array (
31
31
'label ' => $ options ['prototype_name ' ].'label__ ' ,
32
- ), $ options ['entry_options ' ], array (
33
- 'data ' => $ options ['prototype_data ' ],
34
- )));
32
+ ), $ options ['options ' ]);
33
+
34
+ if (null !== $ options ['prototype_data ' ]) {
35
+ $ prototypeOptions ['data ' ] = $ options ['prototype_data ' ];
36
+ }
37
+
38
+ $ prototype = $ builder ->create ($ options ['prototype_name ' ], $ options ['entry_type ' ], $ prototypeOptions );
35
39
$ builder ->setAttribute ('prototype ' , $ prototype ->getForm ());
36
40
}
37
41
Original file line number Diff line number Diff line change @@ -316,4 +316,20 @@ public function testPrototypeData()
316
316
317
317
$ this ->assertSame ('foo ' , $ form ->createView ()->vars ['prototype ' ]->vars ['value ' ]);
318
318
}
319
+
320
+ /**
321
+ * @group legacy
322
+ */
323
+ public function testLegacyPrototypeData ()
324
+ {
325
+ $ form = $ this ->factory ->create ('Symfony\Component\Form\Extension\Core\Type\CollectionType ' , array (), array (
326
+ 'allow_add ' => true ,
327
+ 'prototype ' => true ,
328
+ 'type ' => 'Symfony\Component\Form\Extension\Core\Type\TextType ' ,
329
+ 'options ' => array (
330
+ 'data ' => 'bar ' ,
331
+ ),
332
+ ));
333
+ $ this ->assertSame ('bar ' , $ form ->createView ()->vars ['prototype ' ]->vars ['value ' ]);
334
+ }
319
335
}
You can’t perform that action at this time.
0 commit comments