diff --git a/src/Codeception/Lib/InnerBrowser.php b/src/Codeception/Lib/InnerBrowser.php index f0c52e5..a49cfb5 100644 --- a/src/Codeception/Lib/InnerBrowser.php +++ b/src/Codeception/Lib/InnerBrowser.php @@ -1003,6 +1003,18 @@ private function getFormFromCrawler(Crawler $form) { $fakeDom = new \DOMDocument(); $fakeDom->appendChild($fakeDom->importNode($form->getNode(0), true)); + + //add fields having form attribute with id of this form + $formId = $form->attr('id'); + if ($formId !== null) { + $fakeForm = $fakeDom->firstChild; + $topParent = $form->parents()->last(); + $fieldsByFormAttribute = $topParent->filter("input[form=$formId],select[form=$formId],textarea[form=$formId]"); + foreach ($fieldsByFormAttribute as $field) { + $fakeForm->appendChild($fakeDom->importNode($field, true)); + } + } + $node = $fakeDom->documentElement; $action = (string)$this->getFormUrl($form); $cloned = new Crawler($node, $action, $this->getBaseUrl()); diff --git a/tests/data/app/view/form/input-not-in-form.php b/tests/data/app/view/form/input-not-in-form.php new file mode 100644 index 0000000..006dd76 --- /dev/null +++ b/tests/data/app/view/form/input-not-in-form.php @@ -0,0 +1,16 @@ + +
+