Hi,
I'm trying to set an upper limit to the number of (a particular) DataObject that can be created. Reading a couple of previous threads ([a href=http://www.silverstripe.org/general-questions/show/21226]1[/a], [a href=http://www.silverstripe.org/general-questions/show/5130]2[/a]), I tried to implement the limit via the canCreate function. However, it appears that this function isn't executed when I create & save the DataObject via the CMS (GridField).
The code that doesn't work:
function canCreate($member = null)
{
$returnVal = false;
if (ServiceItem::get()->Count() < 3) { // don't allow adding more than 3 ServiceItems.
$returnVal = true;
}
return $returnVal;
}
How should I implement this limit in SS3?
Thank you.
VWD