public function afterSave($insert, $changedAttributes) { $contentType = ContainerType::getIdByName(ContainerType::CONTENT_CONTAINER); //Create single container after insert if ($insert) { for ($i = 1; $i <= $this->containerCount; $i++) { $container = new Container(['page_id' => $this->id, 'position' => $i, 'is_published' => 0, 'type_id' => $contentType, 'attr' => ['data' => '<b>' . $this->title . ' Editable Content ' . '<b>']]); if (!$container->save()) { \yii\helpers\VarDumper::dump($container->errors); } } } $this->touch('updated_at'); return parent::afterSave($insert, $changedAttributes); }
public function actionCreateContainer($id, $sector, $caller, $type) { $container = new Container(['page_id' => $id, 'position' => 99, 'is_published' => 0, 'type_id' => $type]); $container->save(); return $this->redirect(['/' . $this->id, 'sector' => $sector, 'caller' => $caller]); }