Skip to content

Commit

Permalink
bug #17542 ChoiceFormField of type "select" could be "disabled" (boul…
Browse files Browse the repository at this point in the history
…and)

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"
  • Loading branch information
fabpot committed Feb 26, 2016
2 parents be30748 + 576c4b9 commit d0cac39
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/Symfony/Component/DomCrawler/Field/ChoiceFormField.php
Expand Up @@ -55,6 +55,10 @@ public function hasValue()
*/
public function isDisabled()
{
if (parent::isDisabled() && 'select' === $this->type) {
return true;
}

foreach ($this->options as $option) {
if ($option['value'] == $this->value && $option['disabled']) {
return true;
Expand Down
Expand Up @@ -120,6 +120,14 @@ public function testSelectWithEmptyBooleanAttribute()
$this->assertEquals('bar', $field->getValue());
}

public function testSelectIsDisabled()
{
$node = $this->createSelectNode(array('foo' => false, 'bar' => true), array('disabled' => 'disabled'));
$field = new ChoiceFormField($node);

$this->assertTrue($field->isDisabled(), '->isDisabled() returns true for selects with a disabled attribute');
}

public function testMultipleSelects()
{
$node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple'));
Expand Down

0 comments on commit d0cac39

Please sign in to comment.