8000 bug #17542 ChoiceFormField of type "select" could be "disabled" (boul… · symfony/symfony@d0cac39 · GitHub
[go: up one dir, main page]

Skip to content

Commit d0cac39

Browse files
committed
bug #17542 ChoiceFormField of type "select" could be "disabled" (bouland)
This PR was submitted for the master branch but it was merged into the 2.3 branch instead (closes #17542). Discussion ---------- ChoiceFormField of type "select" could be "disabled" Hi, New PR to add tests from the closed PR #15952 | Q | A | ------------- | --- | Bug fix? | yes | New feature? | no | BC breaks? | no | Deprecations? | no | Tests pass? | yes | Fixed tickets | | License | MIT | Doc PR | Commits ------- 576c4b9 ChoiceFormField of type "select" could be "disabled"
2 parents be30748 + 576c4b9 commit d0cac39

File tree

2 files changed

+12
-0
lines changed

2 files changed

+12
-0
lines changed

src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -55,6 +55,10 @@ public function hasValue()
5555
*/
5656
public function isDisabled()
5757
{
58+
if (parent::isDisabled() && 'select' === $this->type) {
59+
return true;
60+
}
61+
5862
foreach ($this->options as $option) {
5963
if ($option['value'] == $this->value && $option['disabled']) {
6064
return true;

src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -120,6 +120,14 @@ public function testSelectWithEmptyBooleanAttribute()
120120
$this->assertEquals('bar', $field->getValue());
121121
}
122122

123+
public function testSelectIsDisabled()
124+
{
125+
$node = $this->createSelectNode(array('foo' => false, 'bar' => true), array('disabled' => 'disabled'));
126+
$field = new ChoiceFormField($node);
127+
128+
$this->assertTrue($field->isDisabled(), '->isDisabled() returns true for selects with a disabled attribute');
129+
}
130+
123131
public function testMultipleSelects()
124132
{
125133
$node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple'));

0 commit comments

Comments
 (0)
0