ChoiceFormField of type "select" could be "disabled"
This commit is contained in:
parent
be30748bc9
commit
576c4b9b42
@ -55,6 +55,10 @@ class ChoiceFormField extends FormField
|
|||||||
*/
|
*/
|
||||||
public function isDisabled()
|
public function isDisabled()
|
||||||
{
|
{
|
||||||
|
if (parent::isDisabled() && 'select' === $this->type) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
foreach ($this->options as $option) {
|
foreach ($this->options as $option) {
|
||||||
if ($option['value'] == $this->value && $option['disabled']) {
|
if ($option['value'] == $this->value && $option['disabled']) {
|
||||||
return true;
|
return true;
|
||||||
|
@ -120,6 +120,14 @@ class ChoiceFormFieldTest extends FormFieldTestCase
|
|||||||
$this->assertEquals('bar', $field->getValue());
|
$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()
|
public function testMultipleSelects()
|
||||||
{
|
{
|
||||||
$node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple'));
|
$node = $this->createSelectNode(array('foo' => false, 'bar' => false), array('multiple' => 'multiple'));
|
||||||
|
Reference in New Issue
Block a user