I have the following code in one of my forms for the backend cms, it seems that $source will only take numeric array, not associative array.
original code:
$myMediaType = new OptionsetField(
$name = "MediaType",
$title = "Media Type",
$source = array(
"Video" => "Video",
"Audio" => "Audio"
),
$value = "Video"
);
$fields->addFieldToTab('Root.Content.Main', $myMediaType, 'Content');
this will not work, but if I change the $source to a numeric array, it will set the default value.
$myMediaType = new OptionsetField(
$name = "MediaType",
$title = "Media Type",
$source = array("Video", "Audio"),
$value = 0
);
$fields->addFieldToTab('Root.Content.Main', $myMediaType, 'Content');
Does anyone come cross this problem, I would prefer to store string 'Video', 'Audio' into the database rather than integer. Could someone please point me the right direction? Thank you!