The followings are the available columns in table 'attribute_group_description':
Inheritance: extends CActiveRecord
Example #1
0
 public function save()
 {
     $attributeGroup = AttributeGroup::model()->findByPk($this->id);
     if (is_null($attributeGroup)) {
         // is insert
         $attributeGroup = new AttributeGroup();
         $attributeGroup->sort_order = $this->sortOrder;
         $attributeGroup->save();
         $attributeDescription = new AttributeGroupDescription();
         $attributeDescription->attribute_group_id = $attributeGroup->attribute_group_id;
         $attributeDescription->language_id = 1;
         // TODO: read locale
         $attributeDescription->name = $this->name;
         $attributeDescription->save();
     } else {
         $attributeGroup->sort_order = $this->sortOrder;
         $attributeGroup->save();
         $attributeGroup->description->name = $this->name;
         $attributeGroup->description->save();
     }
 }
 public function actionUpdate($id)
 {
     $model = new AttributeGroupForm();
     if (isset($_POST['AttributeGroupForm'])) {
         $model->attributes = $_POST['AttributeGroupForm'];
         if ($model->validate()) {
             $model->save();
             $this->redirect(array('index'));
         }
     } else {
         $model->loadDataFromAttributeGroup($id);
     }
     $groups = CHtml::listData(AttributeGroupDescription::model()->findAll(), 'attribute_group_id', 'name');
     $this->render('update', array('model' => $model, 'groups' => $groups));
 }
 public function actionCreate()
 {
     $model = new AttributeGroup();
     $description = new AttributeGroupDescription();
     $this->performAjaxValidation(array($model, $description), 'attribute-group-form');
     if (isset($_POST[$this->modelName])) {
         $model->setAttributes($_POST[$this->modelName]);
         $description->setAttributes($_POST[$this->modelName . 'Description']);
         $suc = Yii::t('info', 'AttributeGroup was successfully created');
         $err = Yii::t('info', 'Could not update AttributeGroup');
         $description->attribute_group_id = 0;
         $description->locale_code = Yii::app()->getLanguage();
         if ($model->validate() && $description->validate()) {
             if ($model->save()) {
                 $description->attribute_group_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));
 }
Example #4
0
 public function afterDelete()
 {
     // delete dependencies
     AttributeGroupDescription::model()->deleteAll("attribute_group_id={$this->cacheId}");
     parent::afterDelete();
 }