Hello,
I've just started playing around a bit with silverstripe. As a test, I created a Country class, extending DataObject. I use ModelAdmin to manage these countries. Because I also store the ISO code for a country, I would like to have a unique index on that column. Quite ease so far:
class Country extends DataObject {
static $db = array(
'Name' => 'Varchar(100)',
'Description' => 'Varchar(200)',
'Iso3166' => 'Varchar(10)',
);
static $indexes = array(
array( 'type' => 'unique', 'value' => 'Iso3166' )
);
}
However, while testing this new index, I ran into a problem. The ModelAdmin interface does not give any error when I try to enter a country with an already existing ISO code. In fact, it does not do anything. It just keeps displaying the 'saving' animation and nothing else. When I interrupt and go back to the country list, a new EMPTY record seems to be created.
I expected SS to give an error and cancel the Save option. Do I have to program something extra to achieve that behavior?
Jeroen Jansen.