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

Skip to content

Commit 6c96706

Browse files
committed
bug #34059 [DomCrawler] Skip disabled fields processing in Form (sbogx)
This PR was merged into the 3.4 branch. Discussion ---------- [DomCrawler] Skip disabled fields processing in Form | Q | A | ------------- | --- | Branch? | 3.4 | Bug fix? | yes | New feature? | no | Deprecations? | no | Tickets | Fix #28179 | License | MIT Commits ------- c73b042 bug #28179 [DomCrawler] Skip disabled fields processing in Form
2 parents a536342 + c73b042 commit 6c96706

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

src/Symfony/Component/DomCrawler/Form.php

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

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

464456
private function addField(\DOMElement $node)
465457
{
466-
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
458+
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
467459
return;
468460
}
469461

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

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -158,12 +158,12 @@ public function testConstructorHandlesFormValues()
158158
public function testMultiValuedFields()
159159
{
160160
$form = $this->createForm('<form>
161-
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
162-
<input type="text" name="foo" value="foo" disabled="disabled" />
163-
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
164-
<input type="text" name="foo[]" value="foo" disabled="disabled" />
165-
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
166-
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
161+
<input type="text" name="foo[4]" value="foo" />
162+
<input type="text" name="foo" value="foo" />
163+
<input type="text" name="foo[2]" value="foo" />
164+
<input type="text" name="foo[]" value="foo" />
165+
<input type="text" name="bar[foo][]" value="foo" />
166+
<input type="text" name="bar[foo][foobar]" value="foo" />
167167
<input type="submit" />
168168
</form>
169169
');
@@ -226,10 +226,10 @@ public function provideInitializeValues()
226226
[],
227227
],
228228
[
229-
'takes into account disabled input fields',
229+
'skips disabled input fields',
230230
'<input type="text" name="foo" value="foo" disabled="disabled" />
231231
<input type="submit" />',
232-
['foo' => ['InputFormField', 'foo']],
232+
[],
233233
],
234234
[
235235
'appends the submitted button value',

0 commit comments

Comments
 (0)