I am having some problems with the admin of Silverstripe. I defined a database model (see class definitions below), and after I do a dev/build everything is looking as expected. When I try to add a new "package" all the "has one" fields are there with a drop down (see screen shot 1). I also built an importer which imports these packages. When run, everything is looking fine, except when you open a package. Then 'Festival' is correctly coupled. You can see the name, and you can select the drop down. "Troupe", on the other hand, has mysteriously converted to an input field that only shows the id of the record in the other table (See screen shot 2).
Does anyone know what is happening here? Is there something that triggers this behaviour that I am unaware off? Is there something wrong with my code (yes, but related to this problem? ;-))? I have checked the structure of the tables, and there is nothing suspicious there...
Before:
After:
Package.php
class Package extends DataObject {
public static $db = array(
'Number' => 'Int',
'Title' => 'Varchar(255)',
'Description' => 'HTMLText',
'Credits' => 'HTMLText',
);
public static $has_many = array(
'Events' => 'Event',
);
public static $many_many = array(
'Genres' => 'Genre',
);
public static $has_one = array(
'Festival' => 'Festival',
'Troupe' => 'Troupe',
);
}
class PackageAdmin extends ModelAdmin {
public static $managed_models = array('Package'); // Can manage multiple models
static $url_segment = 'packages'; // Linked as /admin/packages/
static $menu_title = 'Packages';
}
Troupe.php
class Troupe extends DataObject {
public static $db = array(
"Name" => "Varchar(255)",
"Description" => "HTMLText",
"Url" => "Varchar(255)",
);
public static $has_many = array(
'Packages' => 'Package.Troupe',
);
}
class TroupeAdmin extends ModelAdmin {
public static $managed_models = array('Troupe','Package'); // Can manage multiple models
static $url_segment = 'troupes'; // Linked as /admin/troupes/
static $menu_title = 'Troupes';
}
Festival.php
class Festival extends DataObject {
public static $db = array(
'Name' => 'Varchar(255)',
'Description' => 'HTMLText'
);
public static $has_many = array(
'Packages' => 'Package.Festival'
);
}
class FestivalAdmin extends ModelAdmin {
public static $managed_models = array('Festival','Package'); // Can manage multiple models
static $url_segment = 'festivals'; // Linked as /admin/festivals/
static $menu_title = 'Festivals';
}