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:
Ingo Schommer 2013-10-22 06:43:36 -07:00
commit 6f41b6fae6
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(!$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)");
}
/**

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