10000 [DomCrawler] Skip disabled fields processing in Form by sbogx · Pull Request #34059 · symfony/symfony · GitHub
[go: up one dir, main page]

Skip to content

[DomCrawler] Skip disabled fields processing in Form #34059

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
Feb 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
bug #28179 [DomCrawler] Skip disabled fields processing in Form
  • Loading branch information
sbogx authored and Bogdan Scordaliu committed Oct 22, 2019
commit c73b042044ef26e0d9b7eec2c6ea9db0a74759ef
10 changes: 1 addition & 9 deletions src/Symfony/Component/DomCrawler/Form.php
Original file line number Diff line number Diff line change
Expand Up @@ -89,10 +89,6 @@ 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 @@ -115,10 +111,6 @@ 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 @@ -463,7 +455,7 @@ private function initialize()

private function addField(\DOMElement $node)
{
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
return;
}

Expand Down
16 changes: 8 additions & 8 deletions src/Symfony/Component/DomCrawler/Tests/FormTest.php
Original file line number Diff line number Diff line change
Expand Up @@ -148,12 +148,12 @@ public function testConstructorHandlesFormValues()
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>
');
Expand Down Expand Up @@ -216,10 +216,10 @@ public function provideInitializeValues()
[],
],
[
'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',
Expand Down
0