March 25

Smart image field for Yii2

This is replacement of classic file upload HTML form element. Advantages of this field are:
– You don’t have to handle file upload yourself. It is encapsulated in ImageUploadAction.
– ImageUploadAction resolves upload name clashes by default.
– If existing model is edited, image field is pre-populated.
– Uploaded image won’t be lost if form has validation errors after submit.
– There is a delete image link besides upload button.
The preferred way to install this extension is through composer.
Either run

or add

to the require section of your composer.json file.
1) Attach ImageUploadAction to designated controller

2) Utilize SmartImageField inside ActiveForm

Screen Shot 2016-02-12 at 3.59.41 PM

Screen Shot 2016-02-12 at 3.59.24 PM

Please follow and like us:

Posted March 25, 2016 by mmedojevic in category "PHP

Leave a Reply

Your email address will not be published. Required fields are marked *