bug #22936 [Form] Mix attr option between guessed options and user options (yceruto)
This PR was merged into the 2.7 branch.
Discussion
----------
[Form] Mix attr option between guessed options and user options
| Q | A
| ------------- | ---
| Branch? | 2.7
| Bug fix? | yes
| New feature? | no
| BC breaks? | no
| Deprecations? | no
| Tests pass? | yes
| Fixed tickets | #19871
| License | MIT
Commits
-------
84f5de902d
mix attr options between type-guess options and user options
This commit is contained in:
commit
621b7698fb
@ -126,7 +126,13 @@ class FormFactory implements FormFactoryInterface
|
||||
|
||||
// user options may override guessed options
|
||||
if ($typeGuess) {
|
||||
$options = array_merge($typeGuess->getOptions(), $options);
|
||||
$attrs = array();
|
||||
$typeGuessOptions = $typeGuess->getOptions();
|
||||
if (isset($typeGuessOptions['attr']) && isset($options['attr'])) {
|
||||
$attrs = array('attr' => array_merge($typeGuessOptions['attr'], $options['attr']));
|
||||
}
|
||||
|
||||
$options = array_merge($typeGuessOptions, $options, $attrs);
|
||||
}
|
||||
|
||||
return $this->createNamedBuilder($property, $type, $data, $options);
|
||||
|
@ -450,7 +450,7 @@ class FormFactoryTest extends TestCase
|
||||
->with('Application\Author', 'firstName')
|
||||
->will($this->returnValue(new TypeGuess(
|
||||
'text',
|
||||
array('attr' => array('maxlength' => 10)),
|
||||
array('attr' => array('class' => 'foo', 'maxlength' => 10)),
|
||||
Guess::MEDIUM_CONFIDENCE
|
||||
)));
|
||||
|
||||
@ -458,7 +458,7 @@ class FormFactoryTest extends TestCase
|
||||
|
||||
$factory->expects($this->once())
|
||||
->method('createNamedBuilder')
|
||||
->with('firstName', 'text', null, array('attr' => array('maxlength' => 11)))
|
||||
->with('firstName', 'text', null, array('attr' => array('class' => 'foo', 'maxlength' => 11)))
|
||||
->will($this->returnValue('builderInstance'));
|
||||
|
||||
$this->builder = $factory->createBuilderForProperty(
|
||||
|
Reference in New Issue
Block a user