BUG: An enum field in the search panel model admin misses an option to not filter on that field

This commit is contained in:
Nico Haase 2013-10-19 14:30:52 +02:00
parent 337a29abce
commit ab10c2ecdc
2 changed files with 21 additions and 2 deletions

View File

@ -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)");
} }
/** /**

View 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());
}
}