Yii 2.0: yii2-illustrated-behavior

ActiveRecord behavior + associated widget
6 followers

Illustrated is a Behavior that makes any ActiveRecord, well, illustrated. It links the ActiveRecord to one (or possibly more) image files. The images have strict proportions, allowing for a clean layout of views and other pages. The uploaded images may have several resolutions.

The Illustrated behavior co-operates with the enclosed Uploader widget. This lets the user crop the image by dragging and zooming it, before uploading it to the server.

Requirements

Yii 2.0

Usage of Illustrated

Illustrated is used like any Behavior of an ActiveRecord. The code should look something like this:

class <model> extends \yii\db\ActiveRecord { 
    ... 
    public function behaviors(){
        return [
            [
                "class" => "sjaakp\illustrated\Illustrated",
                ...     // Illustrated options
            ],
            ...     // other behaviors
        ];
    }
    ...
}

Usage of Uploader

Uploader is an input widget. It can be used in an ActiveForm like this:

use sjaakp\illustrated\Uploader;
 
<?php $form = ActiveForm::begin([
        'options' => ['enctype' => 'multipart/form-data']   // important, needed for file upload
    ]); ?>
 
    ...     // other form fields
 
    <?= $form->field($model, 'file')->widget(Uploader::className(), [
           ...      // Uploader options
        ]) ?>
 
    ...
 
<?php ActiveForm::end(); ?>

Resources

Total 1 comment

#17828 report it
DrMabuse at 2014/07/26 05:44am
Nice

thx for that :)

Leave a comment

Please to leave your comment.

Create extension