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)
1014
1014
$ formId = $ form ->attr ('id ' );
1015
1015
if ($ formId !== null ) {
1016
1016
$ 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
+
1018
1025
$ fieldsByFormAttribute = $ topParent ->filter ("input[form= $ formId],select[form= $ formId],textarea[form= $ formId] " );
1019
1026
foreach ($ fieldsByFormAttribute as $ field ) {
1020
1027
$ fakeForm ->appendChild ($ fakeDom ->importNode ($ field , true ));
@@ -1044,7 +1051,12 @@ protected function getFormFor(Crawler $node)
1044
1051
if (strcasecmp ($ node ->first ()->getNode (0 )->tagName , 'form ' ) === 0 ) {
1045
1052
$ form = $ node ->first ();
1046
1053
} 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
+ }
1048
1060
}
1049
1061
if (!$ form ) {
1050
1062
$ 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