示例#1
0
 public function beforeValidate()
 {
     if (!$this->code) {
         $this->code = yupe\helpers\YText::translit($this->title);
     }
     return parent::beforeValidate();
 }
示例#2
0
 /**
  * beforeValidate
  *
  * @return parent::beforeValidate()
  **/
 public function beforeValidate()
 {
     // Проверяем наличие установленного хозяина галереи
     if (isset($this->owner) && empty($this->owner)) {
         $this->owner = Yii::app()->user->getId();
     }
     return parent::beforeValidate();
 }
示例#3
0
 public function beforeValidate()
 {
     if (!$this->alias) {
         $this->alias = yupe\helpers\YText::translit($this->name);
     }
     if (!$this->lang) {
         $this->lang = Yii::app()->language;
     }
     return parent::beforeValidate();
 }
示例#4
0
 public function beforeValidate()
 {
     if (!$this->ip) {
         $this->ip = Yii::app()->getRequest()->userHostAddress;
     }
     return parent::beforeValidate();
 }
示例#5
0
 public function beforeValidate()
 {
     if (!$this->slug) {
         $this->slug = yupe\helpers\YText::translit($this->name);
     }
     foreach ((array) $this->_eavAttributes as $name => $value) {
         $model = Attribute::model()->getAttributeByName($name);
         if (!$model->isType(Attribute::TYPE_CHECKBOX) && $model->isRequired() && !$value) {
             $this->addError('eav.' . $name, Yii::t("StoreModule.store", "{title} attribute is required", ['title' => $model->title]));
         }
     }
     return parent::beforeValidate();
 }
示例#6
0
 /**
  * @return bool
  */
 public function beforeValidate()
 {
     if ($this->getScenario() === self::SCENARIO_USER) {
         if (!$this->hasProducts) {
             $this->addError('products', Yii::t('OrderModule.order', 'There are no selected products'));
         }
     }
     return parent::beforeValidate();
 }
示例#7
0
 /**
  * Обновляем дату изменения. Если новая запись
  * обновляем необходимые поля:
  *
  * @return void
  */
 public function beforeValidate()
 {
     $this->update_time = new CDbExpression('NOW()');
     if ($this->isNewRecord) {
         $this->create_time = $this->update_time;
         $this->ip = Yii::app()->getRequest()->userHostAddress;
     }
     return parent::beforeValidate();
 }
示例#8
0
文件: Page.php 项目: alextravin/yupe
 public function beforeValidate()
 {
     if (!$this->slug) {
         $this->slug = yupe\helpers\YText::translit($this->title);
     }
     if (!$this->lang) {
         $this->lang = Yii::app()->getLanguage();
     }
     return parent::beforeValidate();
 }
示例#9
0
 public function beforeValidate()
 {
     $this->change_user_id = Yii::app()->user->getId();
     if ($this->isNewRecord) {
         $this->user_id = $this->change_user_id;
     }
     if (!$this->slug) {
         $this->slug = yupe\helpers\YText::translit($this->name);
     }
     return parent::beforeValidate();
 }
示例#10
0
 public function beforeValidate()
 {
     if ($this->markup_type == self::MARKUP_TYPE_RELATION) {
         $this->getValidatorList()->add(CValidator::createValidator('required', $this, 'view_relation'));
     }
     return parent::beforeValidate();
 }
示例#11
0
 /**
  * Предвалидационные действия:
  * 
  * @return void
  */
 public function beforeValidate()
 {
     $this->status = $this->status ?: self::STATUS_DRAFT;
     $this->date = date('Y-m-d', strtotime($this->date));
     return parent::beforeValidate();
 }
示例#12
0
 public function beforeValidate()
 {
     if ($this->isNewRecord) {
         $this->creation_date = new CDbExpression('NOW()');
         $this->user_id = Yii::app()->user->getId();
     }
     return parent::beforeValidate();
 }
示例#13
0
 /**
  * Предвалидационные действия:
  * 
  * @return void
  */
 public function beforeValidate()
 {
     $this->status = $this->status ?: self::STATUS_DRAFT;
     return parent::beforeValidate();
 }
示例#14
0
 /**
  * Предвалидационные действия:
  * 
  * @return void
  */
 public function beforeValidate()
 {
     $this->gender = $this->gender ?: self::GENDER_THING;
     return parent::beforeValidate();
 }
示例#15
0
 /**
  * Метод выполняемый перед валидацией:
  * 
  * @return void
  */
 public function beforeValidate()
 {
     /*
             if($this->getIsNewRecord()) {
        if(empty($this->role)) {
            $this->role = User::getAuthenticatedRole();
        }
             }  
     * 
     */
     return parent::beforeValidate();
 }
示例#16
0
 /**
  * Предвалидационные действия:
  * 
  * @return void
  */
 public function beforeValidate()
 {
     if (empty($this->gender)) {
         $this->gender = self::GENDER_FEMALE;
     }
     return parent::beforeValidate();
 }
示例#17
0
 /**
  * @return bool
  */
 public function beforeValidate()
 {
     if (!$this->slug) {
         $this->slug = yupe\helpers\YText::translit($this->name);
     }
     return parent::beforeValidate();
 }
示例#18
0
文件: Product.php 项目: yupe/yupe
 /**
  * @return bool
  */
 public function beforeValidate()
 {
     foreach ($this->getTypeAttributes() as $attribute) {
         if ($attribute->isType(Attribute::TYPE_CHECKBOX)) {
             continue;
         }
         if ($attribute->isRequired() && (!isset($this->_typeAttributes[$attribute->id]) || '' === $this->_typeAttributes[$attribute->id])) {
             $this->addError($attribute->title, Yii::t("StoreModule.store", "{title} attribute is required", ['title' => $attribute->title]));
         }
     }
     if (!$this->isInStock()) {
         $this->setEmptyQuantity();
     }
     return parent::beforeValidate();
 }
示例#19
0
 /**
  * Обновляем дату изменения. Если новая запись
  * обновляем необходимые поля:
  * 
  * @return void
  */
 public function beforeValidate()
 {
     //$this->change_date = new CDbExpression('NOW()');
     $this->change_date = date("Y-m-d H:i:s");
     if ($this->isNewRecord) {
         $this->creation_date = $this->change_date;
         $this->ip = Yii::app()->getRequest()->userHostAddress;
     }
     return parent::beforeValidate();
 }
示例#20
0
 /**
  * Обновляем дату изменения. Если новая запись
  * обновляем необходимые поля:
  * 
  * @return void
  */
 public function beforeValidate()
 {
     $this->change_date = new CDbExpression('NOW()');
     if ($this->isNewRecord) {
         $this->creation_date = $this->change_date;
         $this->ip = Yii::app()->getRequest()->userHostAddress;
         if (!$this->type) {
             $this->type = self::TYPE_DEFAULT;
         }
     }
     return parent::beforeValidate();
 }
示例#21
0
 public function beforeValidate()
 {
     if ($this->show_destiny_table) {
         $this->getValidatorList()->add(CValidator::createValidator('required', $this, 'source_destiny_table'));
     }
     if ($this->show_event_table) {
         $this->getValidatorList()->add(CValidator::createValidator('required', $this, 'source_event_table'));
     }
     return parent::beforeValidate();
 }