Skip to content

Commit

Permalink
Merge branch '2.7' into 2.8
Browse files Browse the repository at this point in the history
* 2.7:
  [TwigBridge] Fix namespaced classes
  mix attr options between type-guess options and user options
  • Loading branch information
fabpot committed Jun 6, 2017
2 parents fbd6375 + 66dbfdc commit b5ec089
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
8 changes: 7 additions & 1 deletion FormFactory.php
Expand Up @@ -153,7 +153,13 @@ public function createBuilderForProperty($class, $property, $data = null, array

// 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);
Expand Down
4 changes: 2 additions & 2 deletions Tests/FormFactoryTest.php
Expand Up @@ -686,15 +686,15 @@ public function testOptionsCanBeOverridden()
->with('Application\Author', 'firstName')
->will($this->returnValue(new TypeGuess(
'Symfony\Component\Form\Extension\Core\Type\TextType',
array('attr' => array('maxlength' => 10)),
array('attr' => array('class' => 'foo', 'maxlength' => 10)),
Guess::MEDIUM_CONFIDENCE
)));

$factory = $this->getMockFactory(array('createNamedBuilder'));

$factory->expects($this->once())
->method('createNamedBuilder')
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('maxlength' => 11)))
->with('firstName', 'Symfony\Component\Form\Extension\Core\Type\TextType', null, array('attr' => array('class' => 'foo', 'maxlength' => 11)))
->will($this->returnValue('builderInstance'));

$this->builder = $factory->createBuilderForProperty(
Expand Down

0 comments on commit b5ec089

Please sign in to comment.