8000 ChoiceFormField of type "select" could be "disabled" · symfony/symfony@576c4b9 · GitHub
[go: up one dir, main page]

Skip to content

Commit 576c4b9

Browse files
boulandfabpot
authored andcommitted
ChoiceFormField of type "select" could be "disabled"
1 parent be30748 commit 576c4b9

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