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

Commit d0cac39

Browse filesBrowse 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
Copy full SHA for d0cac39

File tree

2 files changed

+12
-0
lines changed
Filter options

2 files changed

+12
-0
lines changed

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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php
+4Lines 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

Copy file name to clipboardExpand all lines: src/Symfony/Component/DomCrawler/Tests/Field/ChoiceFormFieldTest.php
+8Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.