This repository was archived by the owner on Jan 30, 2020. It is now read-only.
File tree Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Expand file tree Collapse file tree 2 files changed +25
-11
lines changed Original file line number Diff line number Diff line change @@ -236,7 +236,7 @@ public function populateValues($data)
236
236
}
237
237
}
238
238
239
- if ($ elementOrFieldset ) {
239
+ if ($ elementOrFieldset !== null ) {
240
240
if ($ elementOrFieldset instanceof FieldsetInterface) {
241
241
$ elementOrFieldset ->populateValues ($ value );
242
242
} else {
Original file line number Diff line number Diff line change @@ -1403,20 +1403,34 @@ public function testTargetElementBeingNullNotCausingAnError()
1403
1403
{
1404
1404
$ form = new Form ();
1405
1405
1406
- $ form ->add ([
1407
- 'type ' => 'Zend\Form\Element\Collection ' ,
1408
- 'name ' => 'fieldsets ' ,
1409
- 'options ' => [
1410
- 'count ' => 2
1406
+ $ form ->add (
1407
+ [
1408
+ 'type ' => \Zend \Form \Element \Collection::class,
1409
+ 'name ' => 'fieldsets ' ,
1410
+ 'options ' => [
1411
+ 'count ' => 2
1412
+ ]
1411
1413
]
1412
- ] );
1414
+ );
1413
1415
1414
1416
$ collection = $ form ->get ('fieldsets ' );
1415
- $ data = [];
1416
- $ data ['fieldsets ' ] = ['red ' , 'green ' , 'blue ' ];
1417
+ $ data = [
1418
+ 'fieldsets ' => [
1419
+ 'red ' ,
1420
+ 'green ' ,
1421
+ 'blue '
1422
+ ]
1423
+ ];
1417
1424
1418
- $ form ->populateValues ($ data );
1425
+ $ form ->setData ($ data );
1426
+ $ form ->isValid ();
1419
1427
1420
- $ this ->addToAssertionCount (1 ); // expect no exception being thrown
1428
+ // expect the fieldsets key to be an empty array since there's no valid targetElement
1429
+ $ this ->assertEquals (
1430
+ [
1431
+ 'fieldsets ' => []
1432
+ ],
1433
+ $ form ->getData ()
1434
+ );
1421
1435
}
1422
1436
}
You can’t perform that action at this time.
0 commit comments