Пример #1
0
 /**
  * Validate required shop attributes
  * @param ShopProduct $model
  * @return bool
  */
 public function validateAttributes(ShopProduct $model)
 {
     $attributes = $model->type->shopAttributes;
     if (empty($attributes) || $model->use_configurations) {
         return true;
     }
     $errors = false;
     foreach ($attributes as $attr) {
         if ($attr->required && !isset($_POST['ShopAttribute'][$attr->name])) {
             $errors = true;
             $model->addError($attr->name, Yii::t('ShopModule.admin', 'FIEND_REQUIRED', array('{FIELD}' => $attr->title)));
         }
     }
     return !$errors;
 }