mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
BUG: An enum field in the search panel model admin misses an option to not filter on that field
This commit is contained in:
parent
337a29abce
commit
ab10c2ecdc
@ -94,7 +94,7 @@ class Enum extends StringField {
|
|||||||
if(!$title) $title = $this->name;
|
if(!$title) $title = $this->name;
|
||||||
if(!$name) $name = $this->name;
|
if(!$name) $name = $this->name;
|
||||||
|
|
||||||
$field = new DropdownField($name, $title, $this->enumValues($hasEmpty), $value, $form);
|
$field = new DropdownField($name, $title, $this->enumValues(false), $value, $form);
|
||||||
if($hasEmpty) {
|
if($hasEmpty) {
|
||||||
$field->setEmptyString($emptyString);
|
$field->setEmptyString($emptyString);
|
||||||
}
|
}
|
||||||
@ -116,7 +116,7 @@ class Enum extends StringField {
|
|||||||
*/
|
*/
|
||||||
public function scaffoldSearchField($title = null) {
|
public function scaffoldSearchField($title = null) {
|
||||||
$anyText = _t('Enum.ANY', 'Any');
|
$anyText = _t('Enum.ANY', 'Any');
|
||||||
return $this->formField($title, null, false, '', null, "($anyText)");
|
return $this->formField($title, null, true, $anyText, null, "($anyText)");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
19
tests/forms/EnumFieldTest.php
Normal file
19
tests/forms/EnumFieldTest.php
Normal file
@ -0,0 +1,19 @@
|
|||||||
|
<?php
|
||||||
|
/**
|
||||||
|
* @package framework
|
||||||
|
* @subpackage tests
|
||||||
|
*/
|
||||||
|
class EnumFieldTest extends SapphireTest {
|
||||||
|
public function testAnyFieldIsPresentInSearchField() {
|
||||||
|
$values = array (
|
||||||
|
'Key' => 'Value'
|
||||||
|
);
|
||||||
|
$enumField = new Enum('testField', $values);
|
||||||
|
|
||||||
|
$searchField = $enumField->scaffoldSearchField();
|
||||||
|
|
||||||
|
$anyText = "(" . _t('Enum.ANY', 'Any') . ")";
|
||||||
|
$this->assertEquals(true, $searchField->getHasEmptyDefault());
|
||||||
|
$this->assertEquals($anyText, $searchField->getEmptyString());
|
||||||
|
}
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user