From af17f5a9ace0ab2013d50f33af9d37f200477d96 Mon Sep 17 00:00:00 2001 From: David Maicher Date: Tue, 3 Mar 2020 14:44:39 +0100 Subject: [PATCH] Revert "bug symfony#28179 [DomCrawler] Skip disabled fields processing in Form" This reverts commit c73b042044ef26e0d9b7eec2c6ea9db0a74759ef. --- src/Symfony/Component/DomCrawler/Form.php | 10 +++++++++- .../Component/DomCrawler/Tests/FormTest.php | 16 ++++++++-------- 2 files changed, 17 insertions(+), 9 deletions(-) diff --git a/src/Symfony/Component/DomCrawler/Form.php b/src/Symfony/Component/DomCrawler/Form.php index 0a86c7e6d406..8a6e28ca86c3 100644 --- a/src/Symfony/Component/DomCrawler/Form.php +++ b/src/Symfony/Component/DomCrawler/Form.php @@ -89,6 +89,10 @@ public function getValues() { $values = []; foreach ($this->fields->all() as $name => $field) { + if ($field->isDisabled()) { + continue; + } + if (!$field instanceof Field\FileFormField && $field->hasValue()) { $values[$name] = $field->getValue(); } @@ -111,6 +115,10 @@ public function getFiles() $files = []; foreach ($this->fields->all() as $name => $field) { + if ($field->isDisabled()) { + continue; + } + if ($field instanceof Field\FileFormField) { $files[$name] = $field->getValue(); } @@ -455,7 +463,7 @@ private function initialize() private function addField(\DOMElement $node) { - if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) { + if (!$node->hasAttribute('name') || !$node->getAttribute('name')) { return; } diff --git a/src/Symfony/Component/DomCrawler/Tests/FormTest.php b/src/Symfony/Component/DomCrawler/Tests/FormTest.php index 9894eb429a9e..f042513f8d68 100644 --- a/src/Symfony/Component/DomCrawler/Tests/FormTest.php +++ b/src/Symfony/Component/DomCrawler/Tests/FormTest.php @@ -159,12 +159,12 @@ public function testConstructorHandlesFormValues() public function testMultiValuedFields() { $form = $this->createForm('
- - - - - - + + + + + +
'); @@ -227,10 +227,10 @@ public function provideInitializeValues() [], ], [ - 'skips disabled input fields', + 'takes into account disabled input fields', ' ', - [], + ['foo' => ['InputFormField', 'foo']], ], [ 'appends the submitted button value',