Skip to content

Commit

Permalink
[Form] Fixed lacking attributes in DateTimeType
Browse files Browse the repository at this point in the history
  • Loading branch information
fivestar committed Oct 5, 2011
1 parent 1f2e72d commit 828b18f
Show file tree
Hide file tree
Showing 2 changed files with 28 additions and 0 deletions.
Expand Up @@ -55,6 +55,8 @@ public function buildForm(FormBuilder $builder, array $options)
'days',
'empty_value',
'required',
'invalid_message',
'invalid_message_parameters'
)));
$timeOptions = array_intersect_key($options, array_flip(array(
'hours',
Expand All @@ -63,6 +65,8 @@ public function buildForm(FormBuilder $builder, array $options)
'with_seconds',
'empty_value',
'required',
'invalid_message',
'invalid_message_parameters'
)));

// If `widget` is set, overwrite widget options from `date` and `time`
Expand Down
Expand Up @@ -16,6 +16,7 @@
use Symfony\Component\Form\DateTimeField;
use Symfony\Component\Form\DateField;
use Symfony\Component\Form\TimeField;
use Symfony\Component\Form\FormError;

class DateTimeTypeTest extends LocalizedTestCase
{
Expand Down Expand Up @@ -234,4 +235,27 @@ public function testSubmit_differentPattern()

$this->assertDateTimeEquals($dateTime, $form->getData());
}

public function testSubmit_invalidDateTime()
{
$form = $this->factory->create('datetime', null, array(
'invalid_message' => 'Customized invalid message',
));

$form->bind(array(
'date' => array(
'day' => '31',
'month' => '9',
'year' => '2010',
),
'time' => array(
'hour' => '25',
'minute' => '4',
),
));

$this->assertFalse($form->isValid());
$this->assertEquals(array(new FormError('Customized invalid message', array())), $form['date']->getErrors());
$this->assertEquals(array(new FormError('Customized invalid message', array())), $form['time']->getErrors());
}
}

0 comments on commit 828b18f

Please sign in to comment.