Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit 3a8da96

Browse files
committed
bug #35937 Revert "bug #28179 [DomCrawler] Skip disabled fields processing in Form" (dmaicher)
This PR was merged into the 3.4 branch. Discussion ---------- Revert "bug #28179 [DomCrawler] Skip disabled fields processing in Form" | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | #35923 | License | MIT | Doc PR | - Reverts #34059 See #35923 Commits ------- af17f5a Revert "bug #28179 [DomCrawler] Skip disabled fields processing in Form"
2 parents dcf3da8 + af17f5a commit 3a8da96

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

src/Symfony/Component/DomCrawler/Form.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ public function getValues()
8989
{
9090
$values = [];
9191
foreach ($this->fields->all() as $name => $field) {
92+
if ($field->isDisabled()) {
93+
continue;
94+
}
95+
9296
if (!$field instanceof Field\FileFormField && $field->hasValue()) {
9397
$values[$name] = $field->getValue();
9498
}
@@ -111,6 +115,10 @@ public function getFiles()
111115
$files = [];
112116

113117
foreach ($this->fields->all() as $name => $field) {
118+
if ($field->isDisabled()) {
119+
continue;
120+
}
121+
114122
if ($field instanceof Field\FileFormField) {
115123
$files[$name] = $field->getValue();
116124
}
@@ -455,7 +463,7 @@ private function initialize()
455463

456464
private function addField(\DOMElement $node)
457465
{
458-
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
466+
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
459467
return;
460468
}
461469

src/Symfony/Component/DomCrawler/Tests/FormTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ public function testConstructorHandlesFormValues()
159159
public function testMultiValuedFields()
160160
{
161161
$form = $this->createForm('<form>
162-
<input type="text" name="foo[4]" value="foo" />
163-
<input type="text" name="foo" value="foo" />
164-
<input type="text" name="foo[2]" value="foo" />
165-
<input type="text" name="foo[]" value="foo" />
166-
<input type="text" name="bar[foo][]" value="foo" />
167-
<input type="text" name="bar[foo][foobar]" value="foo" />
162+
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
163+
<input type="text" name="foo" value="foo" disabled="disabled" />
164+
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
165+
<input type="text" name="foo[]" value="foo" disabled="disabled" />
166+
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
167+
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
168168
<input type="submit" />
169169
</form>
170170
');
@@ -227,10 +227,10 @@ public function provideInitializeValues()
227227
[],
228228
],
229229
[
230-
'skips disabled input fields',
230+
'takes into account disabled input fields',
231231
'<input type="text" name="foo" value="foo" disabled="disabled" />
232232
<input type="submit" />',
233-
[],
233+
['foo' => ['InputFormField', 'foo']],
234234
],
235235
[
236236
'appends the submitted button value',

0 commit comments

Comments
 (0)