/** * Create form * * @param null $parent * @return array|string|\yii\web\Response * @throws \yii\web\HttpException */ public function actionCreate($parent = null) { return; $class = $this->categoryClass; $model = new $class(); if ($model->load(Yii::$app->request->post())) { if (Yii::$app->request->isAjax) { Yii::$app->response->format = \yii\web\Response::FORMAT_JSON; return ActiveForm::validate($model); } else { if (isset($_FILES) && $this->module->settings['categoryThumb']) { $model->image = UploadedFile::getInstance($model, 'image'); if ($model->image && $model->validate(['image'])) { $model->image = Image::upload($model->image, $this->moduleName); } else { $model->image = ''; } } $model->status = $class::STATUS_ON; $parent = (int) Yii::$app->request->post('parent', null); if ($parent > 0 && ($parentCategory = $class::findOne($parent))) { $model->order_num = $parentCategory->order_num; $model->appendTo($parentCategory); } else { $model->attachBehavior('sortable', SortableModel::className()); $model->makeRoot(); } if (!$model->hasErrors()) { $this->flash('success', Yii::t('easyii', 'Category created')); return $this->redirect(['/admin/' . $this->moduleName, 'id' => $model->primaryKey]); } else { $this->flash('error', Yii::t('easyii', 'Create error. {0}', $model->formatErrors())); return $this->refresh(); } } } else { return $this->render('@easyii/views/category/create', ['model' => $model, 'parent' => $parent]); } }
/** * @return array */ public function behaviors() { return ['sortable' => SortableModel::className(), 'mlBehavior' => ['class' => MultiLanguageBehavior::className(), 'mlConfig' => ['db_table' => 'translations_with_string', 'attributes' => ['label'], 'admin_routes' => ['admin/*']]]]; }
public function behaviors() { return [SortableModel::className(), 'seoBehavior' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true]]; }
public function behaviors() { return [CacheFlush::className(), SortableModel::className()]; }
public function behaviors() { return [SortableModel::className(), 'seo' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'blameable' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_by', 'updatedByAttribute' => 'updated_by']]; }
public function behaviors() { return array_merge_recursive(parent::behaviors(), [CacheFlush::className(), SortableModel::className()]); }
public function behaviors() { return [SortableModel::className()]; }
public function behaviors() { return [SortableModel::className(), 'seoBehavior' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'mlBehavior' => ['class' => MultiLanguageBehavior::className(), 'mlConfig' => ['db_table' => 'translations_with_string', 'attributes' => ['title', 'file', 'image'], 'admin_routes' => ['admin/*']]]]; }
public function behaviors() { return [CacheFlush::className(), SortableModel::className(), 'mlBehavior' => ['class' => MultiLanguageBehavior::className(), 'mlConfig' => ['db_table' => 'translations_with_string', 'attributes' => ['title', 'short', 'text'], 'admin_routes' => ['admin/*']]]]; }
public function behaviors() { return [SortableModel::className(), 'seo' => SeoBehavior::className(), 'sluggable' => ['class' => SluggableBehavior::className(), 'attribute' => 'title', 'ensureUnique' => true], 'blameable' => ['class' => BlameableBehavior::className(), 'createdByAttribute' => 'created_by', 'updatedByAttribute' => 'updated_by'], 'timestamp' => ['class' => TimestampBehavior::className(), 'attributes' => [ActiveRecord::EVENT_BEFORE_INSERT => ['created_at', 'updated_at'], ActiveRecord::EVENT_BEFORE_UPDATE => ['updated_at']], 'value' => new Expression('NOW()')]]; }