Skip to content

Commit 115ba10

Browse files
sbogxBogdan Scordaliu
authored andcommitted
bug symfony#28179 [DomCrawler] Skip disabled fields processing in Form
1 parent 29cffc3 commit 115ba10

File tree

2 files changed

+9
-17
lines changed

2 files changed

+9
-17
lines changed

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

Tests/FormTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -148,12 +148,12 @@ public function testConstructorHandlesFormValues()
148148
public function testMultiValuedFields()
149149
{
150150
$form = $this->createForm('<form>
151-
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
152-
<input type="text" name="foo" value="foo" disabled="disabled" />
153-
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
154-
<input type="text" name="foo[]" value="foo" disabled="disabled" />
155-
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
156-
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
151+
<input type="text" name="foo[4]" value="foo" />
152+
<input type="text" name="foo" value="foo" />
153+
<input type="text" name="foo[2]" value="foo" />
154+
<input type="text" name="foo[]" value="foo" />
155+
<input type="text" name="bar[foo][]" value="foo" />
156+
<input type="text" name="bar[foo][foobar]" value="foo" />
157157
<input type="submit" />
158158
</form>
159159
');
@@ -216,10 +216,10 @@ public function provideInitializeValues()
216216
[],
217217
],
218218
[
219-
'takes into account disabled input fields',
219+
'skips disabled input fields',
220220
'<input type="text" name="foo" value="foo" disabled="disabled" />
221221
<input type="submit" />',
222-
['foo' => ['InputFormField', 'foo']],
222+
[],
223223
],
224224
[
225225
'appends the submitted button value',

0 commit comments

Comments
 (0)