Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Revert "bug symfony#28179 [DomCrawler] Skip disabled fields processing in Form" #35937

Merged
merged 1 commit into from Mar 3, 2020
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
10 changes: 9 additions & 1 deletion src/Symfony/Component/DomCrawler/Form.php
Expand Up @@ -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();
}
Expand All @@ -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();
}
Expand Down Expand Up @@ -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;
}

Expand Down
16 changes: 8 additions & 8 deletions src/Symfony/Component/DomCrawler/Tests/FormTest.php
Expand Up @@ -159,12 +159,12 @@ public function testConstructorHandlesFormValues()
public function testMultiValuedFields()
{
$form = $this->createForm('<form>
<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="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="submit" />
</form>
');
Expand Down Expand Up @@ -227,10 +227,10 @@ public function provideInitializeValues()
[],
],
[
'skips disabled input fields',
'takes into account disabled input fields',
'<input type="text" name="foo" value="foo" disabled="disabled" />
<input type="submit" />',
[],
['foo' => ['InputFormField', 'foo']],
],
[
'appends the submitted button value',
Expand Down