init() public method

public init ( )
Example #1
0
 public function init()
 {
     parent::init();
     $this->formView = '@vendor/albertborsos/yii2-lib/views/fileupload/form';
     $this->fieldOptions['id'] = ArrayHelper::getValue($this->options, 'id');
     $this->options['id'] .= '-form';
     $this->options['enctype'] = 'multipart/form-data';
     $this->options['uploadTemplateId'] = $this->uploadTemplateId ?: '#template-upload';
     $this->options['downloadTemplateId'] = $this->downloadTemplateId ?: '#template-download';
 }
Example #2
0
 /**
  * Initializes the widget.
  */
 public function init()
 {
     if (!$this->model) {
         $this->model = new Media();
     }
     if ($this->ownerModel && !$this->inputContainer) {
         $this->inputContainer = '#' . Html::getInputId($this->ownerModel, $this->ownerModel->getUploadAttribute());
     }
     if ($this->ownerModel && !$this->inputName) {
         $this->inputName = Html::getInputName($this->ownerModel, $this->ownerModel->getUploadAttribute());
     }
     $this->clientOptions = ['autoUpload' => true, 'previewMaxWidth' => 120, 'previewMaxHeight' => 120, 'previewCrop' => true];
     $this->gallery = false;
     if ($this->baseUrl) {
         $this->url = $this->baseUrl . '/upload';
     }
     parent::init();
 }