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
-------
c73b042044
bug symfony#28179 [DomCrawler] Skip disabled fields processing in Form
This commit is contained in:
commit
6c96706381
|
@ -89,10 +89,6 @@ class Form extends Link implements \ArrayAccess
|
|||
{
|
||||
$values = [];
|
||||
foreach ($this->fields->all() as $name => $field) {
|
||||
if ($field->isDisabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if (!$field instanceof Field\FileFormField && $field->hasValue()) {
|
||||
$values[$name] = $field->getValue();
|
||||
}
|
||||
|
@ -115,10 +111,6 @@ class Form extends Link implements \ArrayAccess
|
|||
$files = [];
|
||||
|
||||
foreach ($this->fields->all() as $name => $field) {
|
||||
if ($field->isDisabled()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
if ($field instanceof Field\FileFormField) {
|
||||
$files[$name] = $field->getValue();
|
||||
}
|
||||
|
@ -463,7 +455,7 @@ class Form extends Link implements \ArrayAccess
|
|||
|
||||
private function addField(\DOMElement $node)
|
||||
{
|
||||
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
|
||||
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
|
|
@ -158,12 +158,12 @@ class FormTest extends TestCase
|
|||
public function testMultiValuedFields()
|
||||
{
|
||||
$form = $this->createForm('<form>
|
||||
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="foo" value="foo" disabled="disabled" />
|
||||
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="foo[]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
|
||||
<input type="text" name="foo[4]" value="foo" />
|
||||
<input type="text" name="foo" value="foo" />
|
||||
<input type="text" name="foo[2]" value="foo" />
|
||||
<input type="text" name="foo[]" value="foo" />
|
||||
<input type="text" name="bar[foo][]" value="foo" />
|
||||
<input type="text" name="bar[foo][foobar]" value="foo" />
|
||||
<input type="submit" />
|
||||
</form>
|
||||
');
|
||||
|
@ -226,10 +226,10 @@ class FormTest extends TestCase
|
|||
[],
|
||||
],
|
||||
[
|
||||
'takes into account disabled input fields',
|
||||
'skips disabled input fields',
|
||||
'<input type="text" name="foo" value="foo" disabled="disabled" />
|
||||
<input type="submit" />',
|
||||
['foo' => ['InputFormField', 'foo']],
|
||||
[],
|
||||
],
|
||||
[
|
||||
'appends the submitted button value',
|
||||
|
|
Reference in New Issue