mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
FIX Allow clearing lazyloaded SearchableDropdownField. (#11324)
This commit is contained in:
parent
a8d0d1ef58
commit
9fae48bbd7
@ -29,7 +29,7 @@ trait SearchableDropdownTrait
|
|||||||
'search',
|
'search',
|
||||||
];
|
];
|
||||||
|
|
||||||
private bool $isClearable = false;
|
private bool $isClearable = true;
|
||||||
|
|
||||||
private bool $isLazyLoaded = false;
|
private bool $isLazyLoaded = false;
|
||||||
|
|
||||||
|
@ -24,6 +24,5 @@ class SearchableMultiDropdownField extends MultiSelectField
|
|||||||
$this->setLabelField($labelField);
|
$this->setLabelField($labelField);
|
||||||
$this->addExtraClass('ss-searchable-dropdown-field');
|
$this->addExtraClass('ss-searchable-dropdown-field');
|
||||||
$this->setIsMultiple(true);
|
$this->setIsMultiple(true);
|
||||||
$this->setIsClearable(true);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -205,16 +205,16 @@ class SearchableDropdownTraitTest extends SapphireTest
|
|||||||
$field->setForm($form);
|
$field->setForm($form);
|
||||||
$schema = $field->getSchemaDataDefaults();
|
$schema = $field->getSchemaDataDefaults();
|
||||||
$this->assertFalse($schema['lazyLoad']);
|
$this->assertFalse($schema['lazyLoad']);
|
||||||
$this->assertFalse($schema['clearable']);
|
$this->assertTrue($schema['clearable']);
|
||||||
$this->assertSame('Select or type to search...', $schema['placeholder']);
|
$this->assertSame('Select or type to search...', $schema['placeholder']);
|
||||||
$this->assertTrue($schema['searchable']);
|
$this->assertTrue($schema['searchable']);
|
||||||
$field->setIsLazyLoaded(true);
|
$field->setIsLazyLoaded(true);
|
||||||
$field->setIsClearable(true);
|
$field->setIsClearable(false);
|
||||||
$field->setPlaceholder('My placeholder');
|
$field->setPlaceholder('My placeholder');
|
||||||
$field->setIsSearchable(false);
|
$field->setIsSearchable(false);
|
||||||
$schema = $field->getSchemaDataDefaults();
|
$schema = $field->getSchemaDataDefaults();
|
||||||
$this->assertTrue($schema['lazyLoad']);
|
$this->assertTrue($schema['lazyLoad']);
|
||||||
$this->assertTrue($schema['clearable']);
|
$this->assertFalse($schema['clearable']);
|
||||||
$this->assertSame('My placeholder', $schema['placeholder']);
|
$this->assertSame('My placeholder', $schema['placeholder']);
|
||||||
$this->assertFalse($schema['searchable']);
|
$this->assertFalse($schema['searchable']);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user