8000 [Form] Fix #11694 - Enforce options value type check in some form types by kix · Pull Request #11696 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[Form] Fix #11694 - Enforce options value type check in some form types #11696

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 5 commits into from
Closed
Show file tree
Hide file tree
Changes from 1 commit
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
Prev Previous commit
Next Next commit
[Form] Fix DateType 'years', 'months' and 'days' options to only acce…
…pt arrays
  • Loading branch information
kix committed Aug 19, 2014
commit 2ef8f26fb6f6bfb86f5b628c2f2fe9c23f1a9e0f
3 changes: 3 additions & 0 deletions src/Symfony/Component/Form/Extension/Core/Type/DateType.php
Original file line number Diff line number Diff line change
Expand Up @@ -237,6 +237,9 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)

$resolver->setAllowedTypes(array(
'format' => array('int', 'string'),
'years' => 'array',
'months' => 'array',
'days' => 'array',
));
}

Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -340,6 +340,36 @@ public function testThrowExceptionIfFormatIsInvalid()
));
}

/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfYearsIsInvalid()
{
$this->factory->create('date', null, array(
'years' => 'bad value',
));
}

/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfMonthsIsInvalid()
{
$this->factory->create('date', null, array(
'months' => 'bad value',
));
}

/**
* @expectedException \Symfony\Component\OptionsResolver\Exception\InvalidOptionsException
*/
public function testThrowExceptionIfDaysIsInvalid()
{
$this->factory->create('date', null, array(
'days' => 'bad value',
));
}

public function testSetDataWithDifferentTimezones()
{
$form = $this->factory->create('date', null, array(
Expand Down
0