$search_fields not providing (any) for dropdown fields


#1

Silverstripe Version:
4.3
Question:
I am in the process of upgrading an SS3.6 site to SS4.3. I have a ModelAdmin to maintain a Report dataobject. In SS4.3 the dropdown fields (ReportRead, IncidentCountry) that I specify in $search_fields do not have an (Any) option in the search. Enum fields such as IncidentType do. In SS3.6 they all do. How can I restore the (any) option for search dropdowns?
BTW CountryDropdownField extends SilverStripe\Forms\DropdownField

class Report extends DataObject implements PermissionProvider {
	private static $plural_name = 'Reports';
    private static $singular_name = 'Report';
    
	private static $db = array(
		'IPAddress' => 'Varchar(120)',
		'ReportRead' => 'Boolean',
		'ReportWho' => "Enum(array('Me', 'A Member of my family', 'A friend', 'An acquaintance', 'Other'))",
		'IncidentType' => "Enum(array('Rape/Sexual assault', 'Indecent exposure', 'Stalking or following', 'Touching', 'Childhood sexual assault', 'Sexual harassment', 'Other'))",
		// Where and when
		'IncidentWhere' => 'Text',
		'IncidentCountry' => 'Varchar(12)',
		'IncidentState' => "Enum(array( 'Australian Capital Territory', 'New South Wales', 'Northern Territory', 'Queensland', 'South Australia', 'Tasmania', 'Victoria', 'Western Australia', 'Unknown'))",
		'IncidentWhen' => 'Text',
		// About the offender
		'OffenderName' => 'Text',
		'OffenderAddress' => 'Text',
		'OffenderGender' => "Enum(array('Male', 'Female', 'Unknown'))",
		'OffenderEyecolor' => "Enum(array('Blue', 'Brown', 'Green', 'Hazel', 'Unknown'))",
		'OffenderHaircolor' => "Enum(array('Bald', 'Black', 'Blond', 'Brown', 'Grey', 'Red', 'Unknown'))",
		'OffenderHaircolorOther' => 'Text',
		'OffenderAppearance' => "Enum(array('Aboriginal', 'African', 'Asian', 'Caucasian', 'European', ' Middle Eastern', 'Unknown'))",
		'OffenderHeight' => 'Text',
		'OffenderDescription' => 'Text',
		// About the incident
		'IncidentDescription' => 'Text',
		'IncidentTold' => "Enum(array('No', 'Yes'))",
		'ContactName' => 'Varchar(120)',
		'ContactPhone' => 'Varchar(40)',
		'ContactEmail' => 'Text',
		'ContactOk' => "Enum(array('No', 'Yes'))",
		'Notes' => 'Text',
		'ReportOutcome' => 'Text',
		'ReportOutcomePolice' => 'Text'
	);
	
	private static $has_one = array(
		"SaraFile" => "SaraFile"
	);
	
	private static $summary_fields = array(
		'ID',
		'Created',
		'IPAddress',
		'IncidentType',
		'IncidentState',
		'NameNice',
		'PhoneNice',
		'EmailNice',
		'PhotoAvailable',
		'NotesAvailable',
		'ReportRead'
	);
	
	private static $searchable_fields = array(
		'ID' => array (
			'title' => 'Report ID',
			'field' => 'SilverStripe\Forms\TextField'
		),		
		'ReportRead' => 'SilverStripe\Forms\DropdownField',
		'IncidentType',
		'IncidentCountry' => array(
          'field' => 'CountryDropdownField'
		),	
		'IncidentState',
		'ReportWho',
		'OffenderName' => 'PartialMatchFilter',
		'IncidentDescription' => 'PartialMatchFilter'
	);

#2

I am also “fighting” with the features of 4.3 :smiley:

Add the fields to summary_fields, like

 private static $summary_fields = [
        'ReportRead',
         ....
    ];  

That is working for me.

There is also “some” information related to the searchable_fields available within
SearchableFields

It might be required to customize the fields and filters with getDefaultSearchContext.

Hope that helps


#3

Somehow I feel this is a bug and not a “feature”. A ModelAdmin search pane needs to have an ‘(Any)’ option on all DropdownFields.