8000 merged branch zerkalica/master (PR #4328) · haygus/symfony@96bfdac · GitHub
[go: up one dir, main page]

Skip to content

Commit 96bfdac

Browse files
committed
merged branch zerkalica/master (PR symfony#4328)
Commits ------- c688166 [Form] fixing form type translation_domain inheritance fixed bug with parent property fix is_required field fixed subform translation_domain inheritance some translation_domain inheritance code refactoring added form type translation_domain inheritance tests changed methods place in form type test changed arguments in createNamed method call in FormTypeTest Discussion ---------- FormType translation_domain inheritance Fixes: symfony#3286, symfony#3872, symfony#3938 I found bug in form type parameters inheritance. It's better to inherit some child form element options from parent: translation_domain, required. --------------------------------------------------------------------------- by travisbot at 2012-05-18T13:11:45Z This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1366275) (merged afc32247 into 1e15f21). --------------------------------------------------------------------------- by travisbot at 2012-05-18T13:14:46Z This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1366288) (merged 1794dc79 into 1e15f21). --------------------------------------------------------------------------- by travisbot at 2012-05-18T13:54:41Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1366673) (merged 2f5d0377 into 1e15f21). --------------------------------------------------------------------------- by travisbot at 2012-05-18T14:53:58Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1367306) (merged a4027f3 into 1e15f21). --------------------------------------------------------------------------- by bschussek at 2012-05-20T14:55:14Z This PR has a few outstanding issues and is missing some tests (check read_only tests in FormTypeTest). Otherwise this looks good. --------------------------------------------------------------------------- by travisbot at 2012-05-22T04:48:47Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1396892) (merged 68534d7e into 1e15f21). --------------------------------------------------------------------------- by bschussek at 2012-05-22T07:36:47Z Looks good. Could you please squash your commits into one commit (git rebase -i) and add the prefix "[Form]" to the message of that commit? --------------------------------------------------------------------------- by zerkalica at 2012-05-22T09:36:33Z Ok, but how to push rebased branch ? Use forced push (git push origin :master) or make new branch and new pull request ? --------------------------------------------------------------------------- by bschussek at 2012-05-22T09:43:15Z git push -f origin master --------------------------------------------------------------------------- by travisbot at 2012-05-22T09:53:13Z This pull request [passes](http://travis-ci.org/symfony/symfony/builds/1398573) (merged 05a57095 into e4e3ce6). --------------------------------------------------------------------------- by bschussek at 2012-05-22T09:56:29Z Could you please add a test to FormTypeTest to verify that this actually works? The test already contains tests for the "read_only" functionality that can serve you as template. --------------------------------------------------------------------------- by bschussek at 2012-05-25T06:26:26Z You need to rebase the branch on symfony master so that it becomes mergable: git rebase symfony/master Also, please squash the 8 commits into one. --------------------------------------------------------------------------- by travisbot at 2012-05-25T17:23:01Z This pull request [fails](http://travis-ci.org/symfony/symfony/builds/1435037) (merged 57ee25a1 into ff4d446).
2 parents ff4d446 + c688166 commit 96bfdac

File tree

2 files changed

+38
-2
lines changed

2 files changed

+38
-2
lines changed

src/Symfony/Component/Form/Extension/Core/Type/FormType.php

Lines changed: 11 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public function buildView(FormViewInterface $view, FormInterface $form, array $o
5858
{
5959
$name = $form->getName();
6060
$readOnly = $options['read_only'];
61+
$translationDomain = $options['translation_domain'];
6162

6263
if ($view->hasParent()) {
6364
if ('' === $name) {
@@ -74,6 +75,10 @@ public function buildView(FormViewInterface $view, FormInterface $form, array $o
7475

7576
// Complex fields are read-only if themselves or their parent is.
7677
$readOnly = $readOnly || $view->getParent()->getVar('read_only');
78+
79+
if (!$translationDomain) {
80+
$translationDomain = $view->getParent()->getVar('translation_domain');
81+
}
7782
} else {
7883
$id = $name;
7984
$fullName = $name;
@@ -89,6 +94,10 @@ public function buildView(FormViewInterface $view, FormInterface $form, array $o
8994
$types[] = $type->getName();
9095
}
9196

97+
if (!$translationDomain) {
98+
$translationDomain = 'messages';
99+
}
100+
92101
$view->addVars(array(
93102
'form' => $view,
94103
'id' => $id,
@@ -109,7 +118,7 @@ public function buildView(FormViewInterface $view, FormInterface $form, array $o
109118
'label_attr' => $options['label_attr'],
110119
'compound' => $options['compound'],
111120
'types' => $types,
112-
'translation_domain' => $options['translation_domain'],
121+
'translation_domain' => $translationDomain,
113122
));
114123
}
115124

@@ -185,7 +194,7 @@ public function setDefaultOptions(OptionsResolverInterface $resolver)
185194
'label_attr' => array(),
186195
'virtual' => false,
187196
'compound' => true,
188-
'translation_domain' => 'messages',
197+
'translation_domain' => null,
189198
));
190199

191200
$resolver->setAllowedTypes(array(

src/Symfony/Component/Form/Tests/Extension/Core/Type/FormTypeTest.php

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -186,6 +186,33 @@ public function testPassTranslationDomainToView()
186186
$this->assertSame('test', $view->getVar('translation_domain'));
187187
}
188188

189+
public function testNonTranslationDomainFormWithTranslationDomainParentBeingTranslationDomain()
190+
{
191+
$parent = $this->factory->createNamed('parent', 'form', null, array('translation_domain' => 'test'));
192+
$child = $this->factory->createNamed('child', 'form');
193+
$view = $parent->add($child)->createView();
194+
195+
$this->assertEquals('test', $view['child']->getVar('translation_domain'));
196+
}
197+
198+
public function testTranslationDomainFormWithNonTranslationDomainParentBeingTranslationDomain()
199+
{
200+
$parent = $this->factory->createNamed('parent', 'form');
201+
$child = $this->factory->createNamed('child', 'form', null, array('translation_domain' => 'test'));
202+
$view = $parent->add($child)->createView();
203+
204+
$this->assertEquals('test', $view['child']->getVar('translation_domain'));
205+
}
206+
207+
public function testNonTranlsationDomainFormWithNonTranslationDomainParentBeingTranslationDomainDefault()
208+
{
209+
$parent = $this->factory->createNamed('parent', 'form');
210+
$child = $this->factory->createNamed('child', 'form');
211+
$view = $parent-> 5FEA add($child)->createView();
212+
213+
$this->assertEquals('messages', $view['child']->getVar('translation_domain'));
214+
}
215+
189216
public function testPassDefaultLabelToView()
190217
{
191218
$form = $this->factory->createNamed('__test___field', 'form');

0 commit comments

Comments
 (0)
0