Skip to content

Commit 1e8df09

Browse files
Merge branch '3.4'
* 3.4: [TwigBridge] Fix namespaced classes bumped Symfony version to 3.3.2 updated VERSION for 3.3.1 updated CHANGELOG for 3.3.1 [DependencyInjection] Fix named args support in ChildDefinition [Cache] Fallback to positional when keyed results are broken [HttpFoundation][FrameworkBundle] Revert "trusted proxies" BC break [Cache] MemcachedAdapter not working with TagAwareAdapter Remove closure-proxy leftovers fix used class name in deprecation message [DependencyInjection] Use more clear message when unused environment variables detected [Form][Profiler] Fixes form collector triggering deprecations mitigate BC break with empty trusted_proxies [Profiler] Never wrap in code excerpts [Form][FrameworkBundle] Remove non-existing arg for data_collector.form explain that a role can be an instance of Role [Cache] fix Redis scheme detection Implement ServiceSubscriberInterface in optional cache warmers Deprecate passing a concrete service in optional cache warmers mix attr options between type-guess options and user options
2 parents fb095ae + 687fe73 commit 1e8df09

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

FormFactory.php

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,7 +115,13 @@ public function createBuilderForProperty($class, $property, $data = null, array
115115

116116
// user options may override guessed options
117117
if ($typeGuess) {
118-
$options = array_merge($typeGuess->getOptions(), $options);
118+
$attrs = array();
119+
$typeGuessOptions = $typeGuess->getOptions();
120+
if (isset($typeGuessOptions['attr']) && isset($options['attr'])) {
121+
$attrs = array('attr' => array_merge($typeGuessOptions['attr'], $options['attr']));
122+
}
123+
124+
$options = array_merge($typeGuessOptions, $options, $attrs);
119125
}
120126

121127
return $this->createNamedBuilder($property, $type, $data, $options);

Tests/FormFactoryTest.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -310,15 +310,15 @@ public function testOptionsCanBeOverridden()
310310
->with('Application\Author', 'firstName')
311311
->will($this->returnValue(new TypeGuess(
312312
'Symfony\Component\Form\Extension\Core\Type\TextType',
313-
array('attr' => array('maxlength' => 10)),
313+
array('attr' => array('class' => 'foo', 'maxlength' => 10)),
314314
Guess::MEDIUM_CONFIDENCE
315315
)));
316316

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

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

324324
$this->builder = $factory->createBuilderForProperty(

0 commit comments

Comments
 (0)