Thanks to visit codestin.com
Credit goes to github.com

Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
Expand Up @@ -157,7 +157,7 @@ public function configureOptions(OptionsResolver $resolver)
// For any form that is not represented by a single HTML control,
// errors should bubble up by default
$errorBubbling = function (Options $options) {
return $options['compound'];
return $options['compound'] && !$options['inherit_data'];
};

// If data is given, the form is locked to that data
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -512,6 +512,16 @@ public function testOverrideErrorBubbling()
$this->assertTrue($form->getConfig()->getErrorBubbling());
}

public function testErrorBubblingForCompoundFieldsIsDisabledByDefaultIfInheritDataIsEnabled()
{
$form = $this->factory->create(static::TESTED_TYPE, null, [
'compound' => true,
'inherit_data' => true,
]);

$this->assertFalse($form->getConfig()->getErrorBubbling());
}

public function testPropertyPath()
{
$form = $this->factory->create(static::TESTED_TYPE, null, [
Expand Down Expand Up @@ -729,6 +739,28 @@ public function testPreferOwnHelpTranslationParameters()

$this->assertEquals(['%parent_param%' => 'parent_value', '%override_param%' => 'child_value'], $view['child']->vars['help_translation_parameters']);
}

public function testErrorBubblingDoesNotSkipCompoundFieldsWithInheritDataConfigured()
{
$form = $this->factory->createNamedBuilder('form', self::TESTED_TYPE)
->add(
$this->factory->createNamedBuilder('inherit_data_type', self::TESTED_TYPE, null, [
'inherit_data' => true,
])
->add('child', self::TESTED_TYPE, [
'compound' => false,
'error_bubbling' => true,
])
)
->getForm();
$error = new FormError('error message');
$form->get('inherit_data_type')->get('child')->addError($error);

$this->assertCount(0, $form->getErrors());
$this->assertCount(1, $form->get('inherit_data_type')->getErrors());
$this->assertSame($error, $form->get('inherit_data_type')->getErrors()[0]);
$this->assertCount(0, $form->get('inherit_data_type')->get('child')->getErrors());
}
}

class Money
Expand Down