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(); ?>
Nice
thx for that :)
If you have any questions, please ask in the forum instead.
Signup or Login in order to comment.