Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit84f5de9

Browse files
committed
mix attr options between type-guess options and user options
1 parent20485d1 commit84f5de9

File tree

2 files changed

+9
-3
lines changed

2 files changed

+9
-3
lines changed

‎src/Symfony/Component/Form/FormFactory.php‎

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

127127
// user options may override guessed options
128128
if ($typeGuess) {
129-
$options =array_merge($typeGuess->getOptions(),$options);
129+
$attrs =array();
130+
$typeGuessOptions =$typeGuess->getOptions();
131+
if (isset($typeGuessOptions['attr']) &&isset($options['attr'])) {
132+
$attrs =array('attr' =>array_merge($typeGuessOptions['attr'],$options['attr']));
133+
}
134+
135+
$options =array_merge($typeGuessOptions,$options,$attrs);
130136
}
131137

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

‎src/Symfony/Component/Form/Tests/FormFactoryTest.php‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -450,15 +450,15 @@ public function testOptionsCanBeOverridden()
450450
->with('Application\Author','firstName')
451451
->will($this->returnValue(newTypeGuess(
452452
'text',
453-
array('attr' =>array('maxlength' =>10)),
453+
array('attr' =>array('class' =>'foo','maxlength' =>10)),
454454
Guess::MEDIUM_CONFIDENCE
455455
)));
456456

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

459459
$factory->expects($this->once())
460460
->method('createNamedBuilder')
461-
->with('firstName','text',null,array('attr' =>array('maxlength' =>11)))
461+
->with('firstName','text',null,array('attr' =>array('class' =>'foo','maxlength' =>11)))
462462
->will($this->returnValue('builderInstance'));
463463

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

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp