Symfony\Component\DomCrawler\Field\ChoiceFormField::isDisabled PHP Method

isDisabled() public method

Check if the current selected option is disabled.
public isDisabled ( ) : boolean
return boolean
    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;
            }
        }
        return false;
    }

Usage Example

 public function testRadioButtonIsDisabled()
 {
     $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'foo', 'disabled' => 'disabled'));
     $field = new ChoiceFormField($node);
     $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'bar'));
     $field->addChoice($node);
     $node = $this->createNode('input', '', array('type' => 'radio', 'name' => 'name', 'value' => 'baz', 'disabled' => ''));
     $field->addChoice($node);
     $field->select('foo');
     $this->assertEquals('foo', $field->getValue(), '->getValue() returns the value attribute of the selected radio button');
     $this->assertTrue($field->isDisabled());
     $field->select('bar');
     $this->assertEquals('bar', $field->getValue(), '->getValue() returns the value attribute of the selected radio button');
     $this->assertFalse($field->isDisabled());
     $field->select('baz');
     $this->assertEquals('baz', $field->getValue(), '->getValue() returns the value attribute of the selected radio button');
     $this->assertTrue($field->isDisabled());
 }