public function afterSave($insert, $changedAttributes) { if ($insert) { $this->create(); $elements = (require Yii::getAlias('@worstinme/zoo/applications/default/Elements.php')); if (is_array($elements) && count($elements)) { foreach ($elements as $key => $params) { $element = new Elements(); $element->setAttributes($params); $element->name = $key; $element->app_id = $this->id; $element->allcategories = 1; if (!$element->save()) { print_R($element->errors); } } } } return parent::afterSave($insert, $changedAttributes); }