Skip to content

Commit a9ee9ea

Browse files
committed
Add form elements with form attribute to cloned Form
Fixes Codeception/Codeception#6022
1 parent c718a04 commit a9ee9ea

File tree

1 file changed

+12
-0
lines changed

1 file changed

+12
-0
lines changed

src/Codeception/Lib/InnerBrowser.php

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1003,6 +1003,18 @@ private function getFormFromCrawler(Crawler $form)
10031003
{
10041004
$fakeDom = new \DOMDocument();
10051005
$fakeDom->appendChild($fakeDom->importNode($form->getNode(0), true));
1006+
1007+
//add fields having form attribute with id of this form
1008+
$formId = $form->attr('id');
1009+
if ($formId !== null) {
1010+
$fakeForm = $fakeDom->firstChild;
1011+
$topParent = $form->parents()->last();
1012+
$fieldsByFormAttribute = $topParent->filter("input[form=$formId],select[form=$formId],textarea[form=$formId]");
1013+
foreach ($fieldsByFormAttribute as $field) {
1014+
$fakeForm->appendChild($fakeDom->importNode($field, true));
1015+
}
1016+
}
1017+
10061018
$node = $fakeDom->documentElement;
10071019
$action = (string)$this->getFormUrl($form);
10081020
$cloned = new Crawler($node, $action, $this->getBaseUrl());

0 commit comments

Comments
 (0)