Пример #1
0
 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (!$this->hasModel()) {
         throw new InvalidConfigException('Params $model and $attribute are required for ' . get_class($this) . '.');
     }
     $model = $this->model;
     $file = Html::getAttributeValue($model, $this->attribute);
     if (!$file instanceof File) {
         throw new InvalidConfigException("Attribute {$this->attribute} of " . get_class($model) . ' must be an instance of ' . File::className() . ' for usage in ' . get_class($this) . '.');
     }
 }
Пример #2
0
 /**
  * @inheritdoc
  * @throws InvalidConfigException
  */
 public function init()
 {
     parent::init();
     if (!$this->hasModel()) {
         throw new InvalidConfigException('Params $model and $attribute are required for ' . get_class($this) . '.');
     }
     $model = $this->model;
     $file = Html::getAttributeValue($model, $this->attribute);
     if (!$file instanceof File) {
         throw new InvalidConfigException("Attribute {$this->attribute} of " . get_class($model) . ' must be an instance of ' . File::className() . ' for usage in ' . get_class($this) . '.');
     }
     if (!isset($this->fileInputOptions['id'])) {
         $this->fileInputOptions['id'] = $this->options['id'] . static::ID_FILE_INPUT_SUFFIX;
     }
     if (!isset($this->hiddenInputOptions['id'])) {
         $this->hiddenInputOptions['id'] = $this->options['id'] . static::ID_HIDDEN_INPUT_SUFFIX;
     }
     if (!isset($this->previewContainerOptions['id'])) {
         $this->previewContainerOptions['id'] = $this->options['id'] . static::ID_PREVIEW_CONTAINER_SUFFIX;
     }
     $this->initClientOptions();
 }