8000 [WIP][2.1][Form] Revert some BC breaks by vicb · Pull Request #4134 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[WIP][2.1][Form] Revert some BC breaks #4134

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 8 commits into from
Closed
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Next Next commit
[Form] Revert "merged branch bschussek/issue3990 (PR #3996)"
This reverts commit aebaece, reversing
changes made to fd52f93.
  • Loading branch information
vicb committed Apr 27, 2012
commit 76bbcaf97bdaa4545c28217ec283e514b1e38a2b
Original file line number Diff line number Diff line change
Expand Up @@ -62,9 +62,9 @@ public function buildForm(FormBuilder $builder, array $options)
* @param FormView $view The form view
* @param FormInterface $form The form
*/
public function buildViewBottomUp(FormView $view, FormInterface $form)
public function buildView(FormView $view, FormInterface $form)
{
if (!$view->hasParent() && $view->hasChildren() && $form->hasAttribute('csrf_field_name')) {
if ($form->isRoot() && $form->hasChildren() && $form->hasAttribute('csrf_field_name')) {
$name = $form->getAttribute('csrf_field_name');
$csrfProvider = $form->getAttribute('csrf_provider');
$intention = $form->getAttribute('csrf_intention');
Expand Down
64 changes: 32 additions & 32 deletions src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -96,7 +96,10 @@ public function testRest()
$html = $this->renderRest($view);

$this->assertMatchesXpath($html,
'/div
'/input
[@type="hidden"]
[@id="name__token"]
/following-sibling::div
[
./label[@for="name_field1"]
/following-sibling::input[@type="text"][@id="name_field1"]
Expand All @@ -109,9 +112,6 @@ public function testRest()
[count(../div)=2]
[count(..//label)=2]
[count(..//input)=3]
/following-sibling::input
[@type="hidden"]
[@id="name__token"]
'
);
}
Expand Down Expand Up @@ -144,7 +144,8 @@ public function testRestWithChildrenForms()
$html = $this->renderRest($view);

$this->assertMatchesXpath($html,
'/div
'/input[@type="hidden"][@id="parent__token"]
/following-sibling::div
[
./label[not(@for)]
/following-sibling::div[@id="parent_child1"]
Expand All @@ -171,7 +172,6 @@ public function testRestWithChildrenForms()
]
[count(//label)=4]
[count(//input[@type="text"])=2]
/following-sibling::input[@type="hidden"][@id="parent__token"]
'
);
}
Expand All @@ -189,15 +189,15 @@ public function testRestAndRepeatedWithRow()
$html = $this->renderRest($view);

$this->assertMatchesXpath($html,
'/div
'/input
[@type="hidden"]
[@id="name__token"]
/following-sibling::div
[
./label[@for="name_first"]
/following-sibling::input[@type="text"][@id="name_first"]
]
[count(.//input)=1]
/following-sibling::input
[@type="hidden"]
[@id="name__token"]
'
);
}
Expand All @@ -216,16 +216,16 @@ public function testRestAndRepeatedWithRowPerChild()
$html = $this->renderRest($view);

$this->assertMatchesXpath($html,
'/div
'/input
[@type="hidden"]
[@id="name__token"]
/following-sibling::div
[
./label[@for="name_first"]
/following-sibling::input[@type="text"][@id="name_first"]
]
[count(.//input)=1]
[count(.//label)=1]
/following-sibling::input
[@type="hidden"]
[@id="name__token"]
'
);
}
Expand All @@ -246,16 +246,16 @@ public function testRestAndRepeatedWithWidgetPerChild()
$html = $this->renderRest($view);

$this->assertMatchesXpath($html,
'/div
'/input
[@type="hidden"]
[@id="name__token"]
/following-sibling::div
[
./label[@for="name_first"]
/following-sibling::input[@type="text"][@id="name_first"]
]
[count(//input)=2]
[count(//label)=1]
/following-sibling::input
[@type="hidden"]
[@id="name__token"]
'
);
}
Expand Down Expand Up @@ -293,7 +293,8 @@ public function testCollectionRow()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./div
./input[@type="hidden"][@id="form__token"]
/following-sibling::div
[
./label[not(@for)]
/following-sibling::div
Expand All @@ -310,7 +311,6 @@ public function testCollectionRow()
]
]
]
/following-sibling::input[@type="hidden"][@id="form__token"]
]
[count(.//input)=3]
'
Expand All @@ -327,7 +327,8 @@ public function testForm()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./div
./input[@type="hidden"][@id="name__token"]
/following-sibling::div
[
./label[@for="name_firstName"]
/following-sibling::input[@type="text"][@id="name_firstName"]
Expand All @@ -337,7 +338,6 @@ public function testForm()
./label[@for="name_lastName"]
/following-sibling::input[@type="text"][@id="name_lastName"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
[count(.//input)=3]
'
Expand Down Expand Up @@ -383,8 +383,8 @@ public function testCsrf()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./div
/following-sibling::input[@type="hidden"][@id="name__token"][@value="foo&bar"]
./input[@type="hidden"][@id="name__token"][@value="foo&bar"]
/following-sibling::div
]
[count(.//input[@type="hidden"])=1]
'
Expand All @@ -400,7 +400,8 @@ public function testRepeated()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./div
./input[@type="hidden"][@id="name__token"]
/following-sibling::div
[
./label[@for="name_first"]
/following-sibling::input[@type="text"][@id="name_first"]
Expand All @@ -410,7 +411,6 @@ public function testRepeated()
./label[@for="name_second"]
/following-sibling::input[@type="text"][@id="name_second"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
[count(.//input)=3]
'
Expand All @@ -428,7 +428,8 @@ public function testRepeatedWithCustomOptions()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./div
./input[@type="hidden"][@id="name__token"]
/following-sibling::div
[
./label[@for="name_first"][.="[trans]Test[/trans]"]
/following-sibling::input[@type="text"][@id="name_first"][@required="required"]
Expand All @@ -438,7 +439,6 @@ public function testRepeatedWithCustomOptions()
./label[@for="name_second"][.="[trans]Test2[/trans]"]
/following-sibling::input[@type="text"][@id="name_second"][@required="required"]
]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
[count(.//input)=3]
'
Expand All @@ -454,12 +454,12 @@ public function testSearchInputName()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./div
./input[@type="hidden"][@id="full__token"]
/following-sibling::div
[
./label[@for="full_name"]
/following-sibling::input[@type="search"][@id="full_name"][@name="full[name]"]
]
/following-sibling::input[@type="hidden"][@id="full__token"]
]
[count(//input)=2]
'
Expand Down Expand Up @@ -521,7 +521,8 @@ public function testThemeInheritance($parentTheme, $childTheme)
$this->assertWidgetMatchesXpath($view, array(),
'/div
[
./div
./input[@type="hidden"]
/following-sibling::div
[
./label[.="parent"]
/following-sibling::input[@type="text"]
Expand All @@ -538,7 +539,6 @@ public function testThemeInheritance($parentTheme, $childTheme)
]
]
]
/following-sibling::input[@type="hidden"]
]
'
);
Expand Down
16 changes: 8 additions & 8 deletions src/Symfony/Component/Form/Tests/AbstractLayoutTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -646,11 +646,11 @@ public function testSingleChoiceExpanded()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
./input[@type="hidden"][@id="name__token"]
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
[count(./input)=3]
'
Expand All @@ -669,11 +669,11 @@ public function testSingleChoiceExpandedSkipEmptyValue()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
./input[@type="hidden"][@id="name__token"]
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked]
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
[count(./input)=3]
'
Expand All @@ -691,11 +691,11 @@ public function testSingleChoiceExpandedWithBooleanValue()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
./input[@type="hidden"][@id="name__token"]
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked]
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
[count(./input)=3]
'
Expand All @@ -714,13 +714,13 @@ public function testMultipleChoiceExpanded()
$this->assertWidgetMatchesXpath($form->createView(), array(),
'/div
[
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
./input[@type="hidden"][@id="name__token"]
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)]
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
/following-sibling::label[@for="name_2"][.="[trans]Choice&C[/trans]"]
/following-sibling::input[@type="hidden"][@id="name__token"]
]
[count(./input)=4]
'
Expand Down
Loading
0