Skip to content

Commit e323b60

Browse files
committed
[Form] Fixed failing FormDataExtractorTest
1 parent acdc74b commit e323b60

File tree

2 files changed

+10
-3
lines changed

2 files changed

+10
-3
lines changed

Extension/DataCollector/FormDataExtractor.php

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,9 +123,13 @@ public function extractSubmittedData(FormInterface $form)
123123
*/
124124
public function extractViewVariables(FormView $view)
125125
{
126-
$data = array(
127-
'id' => $view->vars['id']
128-
);
126+
$data = array();
127+
128+
// Set the ID in case no FormInterface object was collected for this
129+
// view
130+
if (isset($view->vars['id'])) {
131+
$data['id'] = $view->vars['id'];
132+
}
129133

130134
foreach ($view->vars as $varName => $value) {
131135
$data['view_vars'][$varName] = $this->valueExporter->exportValue($value);

Tests/Extension/DataCollector/FormDataExtractorTest.php

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -352,13 +352,16 @@ public function testExtractViewVariables()
352352
'b' => 'foo',
353353
'a' => 'bar',
354354
'c' => 'baz',
355+
'id' => 'foo_bar',
355356
);
356357

357358
$this->assertSame(array(
359+
'id' => 'foo_bar',
358360
'view_vars' => array(
359361
'a' => "'bar'",
360362
'b' => "'foo'",
361363
'c' => "'baz'",
364+
'id' => "'foo_bar'",
362365
),
363366
), $this->dataExtractor->extractViewVariables($view));
364367
}

0 commit comments

Comments
 (0)