Permalink
Browse files

[Form] Fixed inheritance of "error_bubbling" in RepeatedType

  • Loading branch information...
1 parent 33f223f commit fe8cebf7cbc42190d7e090c5e40d97aa806ff51a @webmozart webmozart committed Jan 3, 2013
Showing with 39 additions and 0 deletions.
  1. +4 −0 Extension/Core/Type/RepeatedType.php
  2. +35 −0 Tests/Extension/Core/Type/RepeatedTypeTest.php
View
4 Extension/Core/Type/RepeatedType.php
@@ -27,6 +27,10 @@ public function buildForm(FormBuilderInterface $builder, array $options)
$options['first_options']['required'] = $options['required'];
$options['second_options']['required'] = $options['required'];
+ if (!isset($options['options']['error_bubbling'])) {
+ $options['options']['error_bubbling'] = $options['error_bubbling'];
+ }
+
$builder
->addViewTransformer(new ValueToDuplicatesTransformer(array(
$options['first_name'],
View
35 Tests/Extension/Core/Type/RepeatedTypeTest.php
@@ -72,6 +72,41 @@ public function testSetRequired()
$this->assertFalse($form['second']->isRequired());
}
+ public function testSetErrorBubblingToTrue()
+ {
+ $form = $this->factory->create('repeated', null, array(
+ 'error_bubbling' => true,
+ ));
+
+ $this->assertTrue($form->getConfig()->getOption('error_bubbling'));
+ $this->assertTrue($form['first']->getConfig()->getOption('error_bubbling'));
+ $this->assertTrue($form['second']->getConfig()->getOption('error_bubbling'));
+ }
+
+ public function testSetErrorBubblingToFalse()
+ {
+ $form = $this->factory->create('repeated', null, array(
+ 'error_bubbling' => false,
+ ));
+
+ $this->assertFalse($form->getConfig()->getOption('error_bubbling'));
+ $this->assertFalse($form['first']->getConfig()->getOption('error_bubbling'));
+ $this->assertFalse($form['second']->getConfig()->getOption('error_bubbling'));
+ }
+
+ public function testSetErrorBubblingIndividually()
+ {
+ $form = $this->factory->create('repeated', null, array(
+ 'error_bubbling' => true,
+ 'options' => array('error_bubbling' => false),
+ 'second_options' => array('error_bubbling' => true),
+ ));
+
+ $this->assertTrue($form->getConfig()->getOption('error_bubbling'));
+ $this->assertFalse($form['first']->getConfig()->getOption('error_bubbling'));
+ $this->assertTrue($form['second']->getConfig()->getOption('error_bubbling'));
+ }
+
public function testSetOptionsPerChildAndOverwrite()
{
$form = $this->factory->create('repeated', null, array(

0 comments on commit fe8cebf

Please sign in to comment.