Closed lidiexy closed 5 years ago
Hi, Can you upload your code related to gallery extension?
The Model and the Controller... let me know if you need something else... code-ex-gallery-extension.zip
The other piece of code I had is in the view.php to show the images as you documented.
<div class="row"> <?php foreach($model->getBehavior('galleryBehavior')->getImages() as $image) { echo Html::img($image->getUrl('medium')); } ?> </div>
and the _form.php too: `...
<?php
if ($model->isNewRecord) {
echo 'Can not upload images for new record';
} else {
echo \zxbodya\yii2\galleryManager\GalleryManager::widget(
[
'model' => $model,
'behaviorName' => 'galleryBehavior',
'apiRoute' => 'dealer/galleryApi'
]
);
}
?>
... `
I suspect it happens because of use \mootensai\relation\RelationTrait
in you model.
Try to move gallery widget outside your form tag. (widget has some input fields in it, and it looks like those fields are not ignored when form is submitted)
Well, thanks. I tried other solution and is working right now. The RelationTrait is working like a charm, but the problem was with the Yii:$app->request->post()
. After using the RelationTrait
$_POST != Yii::$app->request->post()
Great extension! I'm doing a test with one of my Models (Dealer) to get the extension up and running. I just add one "image" field cause some errors, but when everything seems to be working, and the files were generated, also all "gallery_image" fields were populated. (I can see the image rendered in the "view" action) but the "update" action is through me an Invalid Parameter – yii\base\InvalidParamException. .... backend\models\Dealer has no relation named "photos".
I was checking the GalleryManagerAction/changeData action... and there you have the parameter photo, so what kind of changes I need to do or any other ideas to fix this Exception.
Thanks