Skip to content

Commit 8c0e9c9

Browse files
Merge branch '5.0'
* 5.0: (36 commits) Add test for tagged iterator with numeric index Fix container lint command when a synthetic service is used in combination with the expression language Fix Travis script [Validator][Range] Fix typos [SecurityBundle] Minor fix in LDAP config tree builder [HttpClient] fix requests to hosts that idn_to_ascii() cannot handle Revert "minor #35559 [FrameworkBundle] remove mention of the old Controller class (nicolas-grekas)" [FrameworkBundle] remove redundant PHPDoc in console Descriptor and subclass [Mime] remove phpdoc mentioning Utf8AddressEncoder Add missing phpdoc Remove int return type from FlattenException::getCode [Yaml] fix dumping strings containing CRs [DI] Fix XmlFileLoader bad error message [Form] Handle false as empty value on expanded choices [Messenger] Add ext-redis min version req to tests Tweak message improve PlaintextPasswordEncoder docBlock summary [Validator] Add two missing translations for the Arabic (ar) locale Use some PHP 5.4 constants unconditionally Add new packages on the link script ...
2 parents fcc671d + eb564d7 commit 8c0e9c9

File tree

2 files changed

+17
-9
lines changed

2 files changed

+17
-9
lines changed

Form.php

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,6 +89,10 @@ public function getValues()
8989
{
9090
$values = [];
9191
foreach ($this->fields->all() as $name => $field) {
92+
if ($field->isDisabled()) {
93+
continue;
94+
}
95+
9296
if (!$field instanceof Field\FileFormField && $field->hasValue()) {
9397
$values[$name] = $field->getValue();
9498
}
@@ -111,6 +115,10 @@ public function getFiles()
111115
$files = [];
112116

113117
foreach ($this->fields->all() as $name => $field) {
118+
if ($field->isDisabled()) {
119+
continue;
120+
}
121+
114122
if ($field instanceof Field\FileFormField) {
115123
$files[$name] = $field->getValue();
116124
}
@@ -459,7 +467,7 @@ private function initialize()
459467

460468
private function addField(\DOMElement $node)
461469
{
462-
if (!$node->hasAttribute('name') || !$node->getAttribute('name') || $node->hasAttribute('disabled')) {
470+
if (!$node->hasAttribute('name') || !$node->getAttribute('name')) {
463471
return;
464472
}
465473

Tests/FormTest.php

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -159,12 +159,12 @@ public function testConstructorHandlesFormValues()
159159
public function testMultiValuedFields()
160160
{
161161
$form = $this->createForm('<form>
162-
<input type="text" name="foo[4]" value="foo" />
163-
<input type="text" name="foo" value="foo" />
164-
<input type="text" name="foo[2]" value="foo" />
165-
<input type="text" name="foo[]" value="foo" />
166-
<input type="text" name="bar[foo][]" value="foo" />
167-
<input type="text" name="bar[foo][foobar]" value="foo" />
162+
<input type="text" name="foo[4]" value="foo" disabled="disabled" />
163+
<input type="text" name="foo" value="foo" disabled="disabled" />
164+
<input type="text" name="foo[2]" value="foo" disabled="disabled" />
165+
<input type="text" name="foo[]" value="foo" disabled="disabled" />
166+
<input type="text" name="bar[foo][]" value="foo" disabled="disabled" />
167+
<input type="text" name="bar[foo][foobar]" value="foo" disabled="disabled" />
168168
<input type="submit" />
169169
</form>
170170
');
@@ -227,10 +227,10 @@ public function provideInitializeValues()
227227
[],
228228
],
229229
[
230-
'skips disabled input fields',
230+
'takes into account disabled input fields',
231231
'<input type="text" name="foo" value="foo" disabled="disabled" />
232232
<input type="submit" />',
233-
[],
233+
['foo' => ['InputFormField', 'foo']],
234234
],
235235
[
236236
'appends the submitted button value',

0 commit comments

Comments
 (0)