5121 Posts in 1527 Topics by 1119 members
|
Page:
1
|
Go to End | |
| Author | Topic: | 1501 Views |
-
Indexes in DataObject and ModelAdmin

8 July 2010 at 7:07am
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.
-
Re: Indexes in DataObject and ModelAdmin

9 July 2010 at 7:34am
Hi,
Problem solved. It seems that in such cases a Validator is required. I'm working on it now.
Regards, Jeroen.
-
Re: Indexes in DataObject and ModelAdmin

31 December 2010 at 1:30am
Hi Jeroen,
I am trying to do the exact same thing, have sorted out the index but get no error message in Model Admin. Do you have an example I could have a look at?
Cheers
| 1501 Views | ||
|
Page:
1
|
Go to Top |

