I don't know what's wrong with my code because i think, i have following all the step from github krivochenko/yii2-cropper But button to cropping or delete upload doesn't work and and also the css displayed on the form is not neat like this :
i'm not see any error in console, and i want to include the code i made :
this is in view :
use budyaga\cropper\Widget;
<div class="form-group col-sm-8 col-md-8 col-lg-6">
<?= $form->field($model, 'imageFile')->widget(Widget::className(), [
'uploadUrl' => Url::toRoute($uploadPhoto['url']),
]) ?>
</div>
then this is in controller:
return $this->render('input', [
'model' => $model,
'uploadPhoto' => [
'class' => 'budyaga\cropper\actions\UploadAction',
'url' => 'content/user/create',
'path' => $this->baseApp.'/files/uploads',
]
]);
So what's wrong with this code?
finally, i can understand what wrong with my code.
<?= $form->field($model, 'imageFile')->widget(Widget::className(), [
'uploadUrl' => Url::toRoute($uploadPhoto['url']),
'cropAreaHeight' => 'auto' //here
]) ?>
Upload Photo
index into create action, Upload Photo
should be placed in function action(general) like this:public function actions()
{
return [
'error' => [
'class' => 'yii\web\ErrorAction',
],
'uploadPhoto' => [
'class' => 'budyaga\cropper\actions\UploadAction',
'url' => 'dir_to_save_the_result_of_crop',
'path' => 'path_to_save_the_result_of_crop',
]
];
}
And this widget krivochenko/yii2-cropper can works also really easy to use in yii2