8000 [Form] Revert "merged branch bschussek/issue3990 (PR #3996)" · vicb/symfony@76bbcaf · GitHub
[go: up one dir, main page]

Skip to content

Commit 76bbcaf

Browse files
committed
[Form] Revert "merged branch bschussek/issue3990 (PR symfony#3996)"
This reverts commit aebaece, reversing changes made to fd52f93.
1 parent a01dec0 commit 76bbcaf
Copy full SHA for 76bbcaf

File tree

5 files changed

+79
-114
lines changed

5 files changed

+79
-114
lines changed

src/Symfony/Component/Form/Extension/Csrf/Type/FormTypeCsrfExtension.php

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,9 +62,9 @@ public function buildForm(FormBuilder $builder, array $options)
6262
* @param FormView $view The form view
6363
* @param FormInterface $form The form
6464
*/
65-
public function buildViewBottomUp(FormView $view, FormInterface $form)
65+
public function buildView(FormView $view, FormInterface $form)
6666
{
67-
if (!$view->hasParent() && $view->hasChildren() && $form->hasAttribute('csrf_field_name')) {
67+
if ($form->isRoot() && $form->hasChildren() && $form->hasAttribute('csrf_field_name')) {
6868
$name = $form->getAttribute('csrf_field_name');
6969
$csrfProvider = $form->getAttribute('csrf_provider');
7070
$intention = $form->getAttribute('csrf_intention');

src/Symfony/Component/Form/Tests/AbstractDivLayoutTest.php

Original file line numberDiff line numberDiff line change
@@ -96,7 +96,10 @@ public function testRest()
9696
$html = $this->renderRest($view);
9797

9898
$this->assertMatchesXpath($html,
99-
'/div
99+
'/input
100+
[@type="hidden"]
101+
[@id="name__token"]
102+
/following-sibling::div
100103
[
101104
./label[@for="name_field1"]
102105
/following-sibling::input[@type="text"][@id="name_field1"]
@@ -109,9 +112,6 @@ public function testRest()
109112
[count(../div)=2]
110113
[count(..//label)=2]
111114
[count(..//input)=3]
112-
/following-sibling::input
113-
[@type="hidden"]
114-
[@id="name__token"]
115115
'
116116
);
117117
}
@@ -144,7 +144,8 @@ public function testRestWithChildrenForms()
144144
$html = $this->renderRest($view);
145145

146146
$this->assertMatchesXpath($html,
147-
'/div
147+
'/input[@type="hidden"][@id="parent__token"]
148+
/following-sibling::div
148149
[
149150
./label[not(@for)]
150151
/following-sibling::div[@id="parent_child1"]
@@ -171,7 +172,6 @@ public function testRestWithChildrenForms()
171172
]
172173
[count(//label)=4]
173174
[count(//input[@type="text"])=2]
174-
/following-sibling::input[@type="hidden"][@id="parent__token"]
175175
'
176176
);
177177
}
@@ -189,15 +189,15 @@ public function testRestAndRepeatedWithRow()
189189
$html = $this->renderRest($view);
190190

191191
$this->assertMatchesXpath($html,
192-
'/div
192+
'/input
193+
[@type="hidden"]
194+
[@id="name__token"]
195+
/following-sibling::div
193196
[
194197
./label[@for="name_first"]
195198
/following-sibling::input[@type="text"][@id="name_first"]
196199
]
197200
[count(.//input)=1]
198-
/following-sibling::input
199-
[@type="hidden"]
200-
[@id="name__token"]
201201
'
202202
);
203203
}
@@ -216,16 +216,16 @@ public function testRestAndRepeatedWithRowPerChild()
216216
$html = $this->renderRest($view);
217217

218218
$this->assertMatchesXpath($html,
219-
'/div
219+
'/input
220+
[@type="hidden"]
221+
[@id="name__token"]
222+
/following-sibling::div
220223
[
221224
./label[@for="name_first"]
222225
/following-sibling::input[@type="text"][@id="name_first"]
223226
]
224227
[count(.//input)=1]
225228
[count(.//label)=1]
226-
/following-sibling::input
227-
[@type="hidden"]
228-
[@id="name__token"]
229229
'
230230
);
231231
}
@@ -246,16 +246,16 @@ public function testRestAndRepeatedWithWidgetPerChild()
246246
$html = $this->renderRest($view);
247247

248248
$this->assertMatchesXpath($html,
249-
'/div
249+
'/input
250+
[@type="hidden"]
251+
[@id="name__token"]
252+
/following-sibling::div
250253
[
251254
./label[@for="name_first"]
252255
/following-sibling::input[@type="text"][@id="name_first"]
253256
]
254257
[count(//input)=2]
255258
[count(//label)=1]
256-
/following-sibling::input
257-
[@type="hidden"]
258-
[@id="name__token"]
259259
'
260260
);
261261
}
@@ -293,7 +293,8 @@ public function testCollectionRow()
293293
$this->assertWidgetMatchesXpath($form->createView(), array(),
294294
'/div
295295
[
296-
./div
296+
./input[@type="hidden"][@id="form__token"]
297+
/following-sibling::div
297298
[
298299
./label[not(@for)]
299300
/following-sibling::div
@@ -310,7 +311,6 @@ public function testCollectionRow()
310311
]
311312
]
312313
]
313-
/following-sibling::input[@type="hidden"][@id="form__token"]
314314
]
315315
[count(.//input)=3]
316316
'
@@ -327,7 +327,8 @@ public function testForm()
327327
$this->assertWidgetMatchesXpath($form->createView(), array(),
328328
'/div
329329
[
330-
./div
330+
./input[@type="hidden"][@id="name__token"]
331+
/following-sibling::div
331332
[
332333
./label[@for="name_firstName"]
333334
/following-sibling::input[@type="text"][@id="name_firstName"]
@@ -337,7 +338,6 @@ public function testForm()
337338
./label[@for="name_lastName"]
338339
/following-sibling::input[@type="text"][@id="name_lastName"]
339340
]
340-
/following-sibling::input[@type="hidden"][@id="name__token"]
341341
]
342342
[count(.//input)=3]
343343
'
@@ -383,8 +383,8 @@ public function testCsrf()
383383
$this->assertWidgetMatchesXpath($form->createView(), array(),
384384
'/div
385385
[
386-
./div
387-
/following-sibling::input[@type="hidden"][@id="name__token"][@value="foo&bar"]
386+
./input[@type="hidden"][@id="name__token"][@value="foo&bar"]
387+
/following-sibling::div
388388
]
389389
[count(.//input[@type="hidden"])=1]
390390
'
@@ -400,7 +400,8 @@ public function testRepeated()
400400
$this->assertWidgetMatchesXpath($form->createView(), array(),
401401
'/div
402402
[
403-
./div
403+
./input[@type="hidden"][@id="name__token"]
404+
/following-sibling::div
404405
[
405406
./label[@for="name_first"]
406407
/following-sibling::input[@type="text"][@id="name_first"]
@@ -410,7 +411,6 @@ 10000 public function testRepeated()
410411
./label[@for="name_second"]
411412
/following-sibling::input[@type="text"][@id="name_second"]
412413
]
413-
/following-sibling::input[@type="hidden"][@id="name__token"]
414414
]
415415
[count(.//input)=3]
416416
'
@@ -428,7 +428,8 @@ public function testRepeatedWithCustomOptions()
428428
$this->assertWidgetMatchesXpath($form->createView(), array(),
429429
'/div
430430
[
431-
./div
431+
./input[@type="hidden"][@id="name__token"]
432+
/following-sibling::div
432433
[
433434
./label[@for="name_first"][.="[trans]Test[/trans]"]
434435
/following-sibling::input[@type="text"][@id="name_first"][@required="required"]
@@ -438,7 +439,6 @@ public function testRepeatedWithCustomOptions()
438439
./label[@for="name_second"][.="[trans]Test2[/trans]"]
439440
/following-sibling::input[@type="text"][@id="name_second"][@required="required"]
440441
]
441-
/following-sibling::input[@type="hidden"][@id="name__token"]
442442
]
443443
[count(.//input)=3]
444444
'
@@ -454,12 +454,12 @@ public function testSearchInputName()
454454
$this->assertWidgetMatchesXpath($form->createView(), array(),
455455
'/div
456456
[
457-
./div
457+
./input[@type="hidden"][@id="full__token"]
458+
/following-sibling::div
458459
[
459460
./label[@for="full_name"]
460461
/following-sibling::input[@type="search"][@id="full_name"][@name="full[name]"]
461462
]
462-
/following-sibling::input[@type="hidden"][@id="full__token"]
463463
]
464464
[count(//input)=2]
465465
'
@@ -521,7 +521,8 @@ public function testThemeInheritance($parentTheme, $childTheme)
521521
$this->assertWidgetMatchesXpath($view, array(),
522522
'/div
523523
[
524-
./div
524+
./input[@type="hidden"]
525+
/following-sibling::div
525526
[
526527
./label[.="parent"]
527528
/following-sibling::input[@type="text"]
@@ -538,7 +539,6 @@ public function testThemeInheritance($parentTheme, $childTheme)
538539
]
539540
]
540541
]
541-
/following-sibling::input[@type="hidden"]
542542
]
543543
'
544544
);

src/Symfony/Component/Form/Tests/AbstractLayoutTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -646,11 +646,11 @@ public function testSingleChoiceExpanded()
646646
$this->assertWidgetMatchesXpath($form->createView(), array(),
647647
'/div
648648
[
649-
./input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
649+
./input[@type="hidden"][@id="name__token"]
650+
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@value="&a"][@checked]
650651
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
651652
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][@value="&b"][not(@checked)]
652653
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
653-
/following-sibling::input[@type="hidden"][@id="name__token"]
654654
]
655655
[count(./input)=3]
656656
'
@@ -669,11 +669,11 @@ public function testSingleChoiceExpandedSkipEmptyValue()
669669
$this->assertWidgetMatchesXpath($form->createView(), array(),
670670
'/div
671671
[
672-
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
672+
./input[@type="hidden"][@id="name__token"]
673+
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked]
673674
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
674675
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
675676
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
676-
/following-sibling::input[@type="hidden"][@id="name__token"]
677677
]
678678
[count(./input)=3]
679679
'
@@ -691,11 +691,11 @@ public function testSingleChoiceExpandedWithBooleanValue()
691691
$this->assertWidgetMatchesXpath($form->createView(), array(),
692692
'/div
693693
[
694-
./input[@type="radio"][@name="name"][@id="name_0"][@checked]
694+
./input[@type="hidden"][@id="name__token"]
695+
/following-sibling::input[@type="radio"][@name="name"][@id="name_0"][@checked]
695696
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
696697
/following-sibling::input[@type="radio"][@name="name"][@id="name_1"][not(@checked)]
697698
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
698-
/following-sibling::input[@type="hidden"][@id="name__token"]
699699
]
700700
[count(./input)=3]
701701
'
@@ -714,13 +714,13 @@ public function testMultipleChoiceExpanded()
714714
$this->assertWidgetMatchesXpath($form->createView(), array(),
715715
'/div
716716
[
717-
./input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
717+
./input[@type="hidden"][@id="name__token"]
718+
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_0"][@checked][not(@required)]
718719
/following-sibling::label[@for="name_0"][.="[trans]Choice&A[/trans]"]
719720
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_1"][not(@checked)][not(@required)]
720721
/following-sibling::label[@for="name_1"][.="[trans]Choice&B[/trans]"]
721722
/following-sibling::input[@type="checkbox"][@name="name[]"][@id="name_2"][@checked][not(@required)]
722723
/following-sibling::label[@for="name_2"][.="[trans]Choice&C[/trans]"]
723-
/following-sibling::input[@type="hidden"][@id="name__token"]
724724
]
725725
[count(./input)=4]
726726
'

0 commit comments

Comments
 (0)
0