Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

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

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

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.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 9 additions & 1 deletion 10 src/Symfony/Component/DomCrawler/Form.php
Original file line number Diff line number Diff line change
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 16 src/Symfony/Component/DomCrawler/Tests/FormTest.php
Original file line number Diff line number Diff line change
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
Morty Proxy This is a proxified and sanitized view of the page, visit original site.