File tree Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Expand file tree Collapse file tree 1 file changed +14
-2
lines changed Original file line number Diff line number Diff line change @@ -1014,7 +1014,14 @@ private function getFormFromCrawler(Crawler $form)
10141014 $ formId = $ form ->attr ('id ' );
10151015 if ($ formId !== null ) {
10161016 $ fakeForm = $ fakeDom ->firstChild ;
1017- $ topParent = $ form ->parents ()->last ();
1017+
1018+ // The parents() method is deprecated since symfony/dom-crawler v5.3 (https://github.com/symfony/symfony/pull/39684)
1019+ if (method_exists ($ form , 'ancestors ' )) {
1020+ $ topParent = $ form ->ancestors ()->last ();
1021+ } else {
1022+ $ topParent = $ form ->parents ()->last ();
1023+ }
1024+
10181025 $ fieldsByFormAttribute = $ topParent ->filter ("input[form= $ formId],select[form= $ formId],textarea[form= $ formId] " );
10191026 foreach ($ fieldsByFormAttribute as $ field ) {
10201027 $ fakeForm ->appendChild ($ fakeDom ->importNode ($ field , true ));
@@ -1044,7 +1051,12 @@ protected function getFormFor(Crawler $node)
10441051 if (strcasecmp ($ node ->first ()->getNode (0 )->tagName , 'form ' ) === 0 ) {
10451052 $ form = $ node ->first ();
10461053 } else {
1047- $ form = $ node ->parents ()->filter ('form ' )->first ();
1054+ // The parents() method is deprecated since symfony/dom-crawler v5.3 (https://github.com/symfony/symfony/pull/39684)
1055+ if (method_exists ($ node , 'ancestors ' )) {
1056+ $ form = $ node ->ancestors ()->filter ('form ' )->first ();
1057+ } else {
1058+ $ form = $ node ->parents ()->filter ('form ' )->first ();
1059+ }
10481060 }
10491061 if (!$ form ) {
10501062 $ this ->fail ('The selected node is not a form and does not have a form ancestor. ' );
You can’t perform that action at this time.
0 commit comments