/** * @inheritdoc */ public function init() { parent::init(); if ($this->model === null) { throw InvalidConfigException('"model" cannot be empty.'); } //The status for new uploaded files must be Media::STATUS_TEMP, because if you upload a file with status Media::STATUS_PERMANENT and // the user abort the form without submitting it then the files are without any reference to the model and useless stored in the media table. $this->mediaOptions['status'] = \kmergen\media\models\Media::STATUS_TEMP; }
<?php $form = ActiveForm::begin(); ?> <div class="box-body"> <?php echo $form->field($model, 'album_id'); ?> <?php echo $form->field($model, 'album_position'); ?> <?php echo $form->field($model, 'status'); ?> <?php echo $form->field($model, 'targetUrl', ['inputTemplate' => '<div class="input-group"><span class="input-group-addon">' . Yii::getAlias('@web') . '/</span>{input}</div>']); ?> <?php echo \kmergen\media\widgets\fileupload\FileUpload::widget(['acceptFileExtensions' => 'jpg,jpeg,png', 'fileInputOptions' => ['accept' => 'image/*'], 'mediaOptions' => ['thumbStyle' => 'xsmall'], 'clientOptions' => ['autoUpload' => true, 'maxFileSize' => 10000000, 'minFileSize' => 100, 'disableValidation' => true, 'disableImageResize' => '/Android(?!.*Chrome)|Opera/ .test(window.navigator && navigator.userAgent)', 'disableImageResize' => true]]); ?> </div> </div> </div> </div><!-- _form --> </div>