mirror of
https://github.com/silverstripe/silverstripe-framework
synced 2024-10-22 14:05:37 +02:00
Merge pull request #2566 from NicoHaase/master
BUG: An enum field in the search panel model admin misses an option to not filter on that field
This commit is contained in:
commit
6f41b6fae6
@ -94,7 +94,7 @@ class Enum extends StringField {
|
||||
if(!$title) $title = $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) {
|
||||
$field->setEmptyString($emptyString);
|
||||
}
|
||||
@ -116,7 +116,7 @@ class Enum extends StringField {
|
||||
*/
|
||||
public function scaffoldSearchField($title = null) {
|
||||
$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