Silverstripe 3.1.3
Hoping this is a simple one but I have some dataobjects being managed through ModelAdmin. One of the fields is simply a day name field which is being stored as an Enum field with options 1 - 7.
In the filter on the left hand side the dropdown shows the values 1 - 7, but I would like it to read 'Monday, Tuesday etc'. How do I change this?
I only have the field storing it as a number as I want to be able to sort in the correct week order, so open to any better ways of doing this.
public static $db = array (
'Day' => 'Enum("1,2,3,4,5,6,7")',
);
public static $summary_fields = array(
'Term.Title' => 'Term',
'DayName' => 'Day',
'Course.Title' => 'Class',
'StartTime' => 'Start',
'EndTime' => 'End',
'Studio' => 'Studio'
);
private static $searchable_fields = array(
'Day',
'Studio',
'Instructor.Name' => 'PartialMatchFilter',
'Term.Title' => 'PartialMatchFilter',
'Course.Title' => 'PartialMatchFilter'
);
public function DayName(){
$day_number = $this->Day;
switch($day_number){
case 1:
$day = 'Monday';
break;
case 2:
$day = 'Tuesday';
break;
case 3:
$day = 'Wednesday';
break;
case 4:
$day = 'Thursday';
break;
case 5:
$day = 'Friday';
break;
case 6:
$day = 'Saturday';
break;
case 7:
$day = 'Sunday';
break;
}
return $day;
}