oxy-coach / yii2-images-upload-widget
Images upload widget working with yii2 image behavior
v1.0.1
2018-08-21 08:59 UTC
Requires
- php: >=7.0
- oxy-coach/yii2-image-behavior: >= 1.2.0
- yiisoft/yii2-jui: *
This package is not auto-updated.
Last update: 2024-11-10 05:51:24 UTC
README
Images upload widget working with ImageBehavior with sorting and deleting images via ajax.
Installation via Composer
Run the following command
$ composer require oxy-coach/yii2-images-upload-widget "*"
or add
$ "oxy-coach/yii2-images-upload-widget": "*"
to the require section of your composer.json
file.
Configuring
Add action in the controller, for example:
use oxycoach\imageswidget\SortImagesAction; use oxycoach\imageswidget\DeleteImagesAction; \\ ... public function actions() { return [ 'sort-images' => [ 'class' => SortImagesAction::class, 'modelName' => MyModel::class, ], 'delete-image' => [ 'class' => DeleteImagesAction::class, 'modelName' => MyModel::class, ], ]; }
Usage
use oxycoach\imageswidget\ImagesUploadWidget; <?php $form = ActiveForm::begin(['options' => ['enctype' => 'multipart/form-data']]); ?> \\ ... <?= ImagesUploadWidget::widget([ 'form' => $form, 'model' => $model, 'name' => 'files', 'multiple' => true, 'size' => 'preview', 'sortAction' => ['sort-images'], 'deleteAction' => ['delete-image'], ]) ?>