コード例 #1
0
 public function actionDeleteContainer($id, $sector)
 {
     $model = Container::findOne($id);
     $caller = $model->page->type->name;
     $model->delete();
     return $this->redirect(['/' . $this->id, 'sector' => $sector, 'caller' => $caller]);
 }
コード例 #2
0
 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);
 }
コード例 #3
0
 /**
  * @return \yii\db\ActiveQuery
  */
 public function getContainer()
 {
     return $this->hasOne(Container::className(), ['id' => 'id']);
 }