8000 merged branch mpiecko/master (PR #5280) · symfony/symfony@03f34a9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 03f34a9

Browse files
committed
merged branch mpiecko/master (PR #5280)
Commits ------- 58ebd1b [Form] Fixed error bubbling from DateTime widget - Issue #5270 8ea1607 Update src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php Discussion 10000 ---------- [Form] Fixed error bubbling from DateTime widget - Issue #5270 This is related to #5270 --------------------------------------------------------------------------- by mpiecko at 2012-08-16T19:37:45Z Travisbot shows something like this in it's log: [Composer\Downloader\TransportException] The "http://nodeload.github.com/phingofficial/phing/zipball/2.4.12" file could not be downloaded (HTTP/1.1 500 Internal Server Error) So is it my PR ot Travis CI who fails ... ? I saw this error in some other PR's ... --------------------------------------------------------------------------- by stloyd at 2012-08-16T20:40:39Z It's GitHub =) --------------------------------------------------------------------------- by mpiecko at 2012-08-17T09:36:31Z Bad GitHub :) --------------------------------------------------------------------------- by bschussek at 2012-08-17T11:21:39Z Could you please add a test to DateTimeTypeTest? --------------------------------------------------------------------------- by mpiecko at 2012-08-17T12:23:40Z Sure! --------------------------------------------------------------------------- by bschussek at 2012-08-30T08:20:08Z :+1:
2 parents 548db6d + 58ebd1b commit 03f34a9

File tree

2 files changed

+54
-2
lines changed

2 files changed

+54
-2
lines changed

src/Symfony/Component/Form/Extension/Core/Type/DateTimeType.php

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -140,8 +140,8 @@ public function buildForm(FormBuilderInterface $builder, array $options)
140140
$dateOptions['format'] = $options['date_format'];
141141
}
142142

143-
$dateOptions['input'] = 'array';
144-
$timeOptions['input'] = 'array';
143+
$dateOptions['input'] = $timeOptions['input'] = 'array';
144+
$dateOptions['error_bubbling'] = $timeOptions['error_bubbling'] = true;
145145

146146
$builder
147147
->addViewTransformer(new DataTransformerChain(array(
@@ -231,6 +231,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
231231
// Don't modify \DateTime classes by reference, we treat
232232
// them like immutable value objects
233233
'by_reference' => false,
234+
'error_bubbling' => false,
234235
// If initialized with a \DateTime object, FormType initializes
235236
// this option to "\DateTime". Since the internal, normalized
236237
// representation is not \DateTime, but an array, we need to unset

src/Symfony/Component/Form/Tests/Extension/Core/Type/DateTimeTypeTest.php

Lines changed: 51 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,8 @@
1111

1212
namespace Symfony\Component\Form\Tests\Extension\Core\Type;
1313

14+
use Symfony\Component\Form\FormError;
15+
1416
class DateTimeTypeTest extends LocalizedTestCase
1517
{
1618
public function testSubmit_dateTime()
@@ -386,4 +388,53 @@ public function testDontPassHtml5TypeIfNotSingleText()
386388
$view = $form->createView();
387389
$this->assertFalse(isset($view->vars['type']));
388390
}
391+
392+
public function testDateTypeChoiceErrorsBubbleUp()
393+
{
394+
$error = new FormError('Invalid!');
395+
$form = $this->factory->create('datetime', null);
396+
397+
$form['date']->addError($error);
398+
399+
$this->assertSame(array(), $form['date']->getErrors());
400+
$this->assertSame(array($error), $form->getErrors());
401+
}
402+
403+
public function testDateTypeSingleTextErrorsBubbleUp()
404+
{
405+
$error = new FormError('Invalid!');
406+
$form = $this->factory->create('datetime', null, array(
407+
'date_widget' => 'single_text'
408+
));
409+
410+
$form['date']->addError($error);
411+
412+
$this->assertSame(array(), $form['date']->getErrors());
413+
$this->assertSame(array($error), $form->getErrors());
414+
}
415+
416+
public function testTimeTypeChoiceErrorsBubbleUp()
417+
{
418+
$error = new FormError('Invalid!');
419+
$form = $this->factory->create('datetime', null);
420+
421+
$form['time']->addError($error);
422+
423+
$this->assertSame(array(), $form['time']->getErrors());
424+
$this->assertSame(array($error), $form->getErrors());
425+
}
426+
427+
public function testTimeTypeSingleTextErrorsBubbleUp()
428+
{
429+
$error = new FormError('Invalid!');
430+
$form = $this->factory->create('datetime', null, array(
431+
'time_widget' => 'single_text'
432+
));
433+
434+
$form['time']->addError($error);
435+
436+
$this->assertSame(array(), $form['time']->getErrors());
437+
$this->assertSame(array($error), $form->getErrors());
438+
}
439+
389440
}

0 commit comments

Comments
 (0)
0