public function actionAdmin() { $model = new Attribute('search'); $model->unsetAttributes(); if (isset($_GET['Attribute'])) { $model->setAttributes($_GET['Attribute']); } $this->render('admin', array('model' => $model)); }
/** * Создает новую модель атрибута. * Если создание прошло успешно - перенаправляет на просмотр. * * @return void */ public function actionCreate() { $model = new Attribute(); // Uncomment the following line if AJAX validation is needed // $this->performAjaxValidation($model); if (($data = Yii::app()->getRequest()->getPost('Attribute')) !== null) { $model->setAttributes($data); if ($model->save()) { Yii::app()->user->setFlash(yupe\widgets\YFlashMessages::SUCCESS_MESSAGE, Yii::t('StoreModule.attribute', 'Атрибут создан.')); $this->redirect((array) Yii::app()->getRequest()->getPost('submit-type', ['create'])); } } $this->render('create', ['model' => $model]); }
public function actionCreate() { $model = new Attribute(); $description = new AttributeDescription(); $this->performAjaxValidation(array($model, $description), 'attribute-form'); if (isset($_POST[$this->modelName])) { $model->setAttributes($_POST[$this->modelName]); $description->setAttributes($_POST[$this->modelName . 'Description']); $suc = Yii::t('info', 'Attribute was successfully created'); $err = Yii::t('info', 'Could not update Attribute'); $description->attribute_id = 0; $description->locale_code = Yii::app()->getLanguage(); if ($model->validate() && $description->validate()) { if ($model->save()) { $description->attribute_id = $model->id; $description->save(); Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_SUCCESS, $suc); if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('_view', array('model' => $model, 'description' => $description), false, true); Yii::app()->end(); } else { $this->redirect(array('view', 'id' => $model->id)); } } else { Yii::app()->user->setFlash(TbHtml::ALERT_COLOR_ERROR, $err); } } else { $description->validate(); } } if (Yii::app()->getRequest()->getIsAjaxRequest()) { $this->renderPartial('_form', array('model' => $model, 'description' => $description), false, true); Yii::app()->end(); } $this->render('create', array('model' => $model, 'description' => $description)); }
/** * */ public function actionIndex() { $model = new Attribute('search'); $model->unsetAttributes(); $attributeGroup = new AttributeGroup('search'); $attributeGroup->unsetAttributes(); if (isset($_GET['Attribute'])) { $model->setAttributes($_GET['Attribute']); } $this->render('index', ['model' => $model, 'attributeGroup' => $attributeGroup]); }