예제 #1
0
 /**
  * Validate required store attributes
  * @param StoreProduct $model
  * @return bool
  */
 public function validateAttributes(StoreProduct $model)
 {
     $attributes = $model->type->storeAttributes;
     if (empty($attributes) || $model->use_configurations) {
         return true;
     }
     $errors = false;
     foreach ($attributes as $attr) {
         if ($attr->required && !isset($_POST['StoreAttribute'][$attr->name])) {
             $errors = true;
             $model->addError($attr->name, Yii::t('StoreModule.admin', 'Поле %s обязательно для заполнения', array('%s' => $attr->title)));
         }
     }
     return !$errors;
 }