Merge pull request #492 from ajshort/multisites

Fix ModelAdmin When Managed Models Is Array
This commit is contained in:
Sam Minnée 2012-05-27 16:53:28 -07:00
commit f80091f16a

View File

@ -96,14 +96,18 @@ abstract class ModelAdmin extends LeftAndMain {
/** /**
* Initialize the model admin interface. Sets up embedded jquery libraries and requisite plugins. * Initialize the model admin interface. Sets up embedded jquery libraries and requisite plugins.
*
* @todo remove reliance on urlParams
*/ */
public function init() { public function init() {
parent::init(); parent::init();
$models = $this->getManagedModels(); $models = $this->getManagedModels();
$this->modelClass = (isset($this->urlParams['ModelClass'])) ? $this->urlParams['ModelClass'] : key($models);
if($this->request->param('ModelClass')) {
$this->modelClass = $this->request->param('ModelClass');
} else {
reset($models);
$this->modelClass = key($models);
}
// security check for valid models // security check for valid models
if(!array_key_exists($this->modelClass, $models)) { if(!array_key_exists($this->modelClass, $models)) {