zxbodya / yii2-gallery-manager

93 stars 61 forks source link

Call to a member function getBehavior() on null #83

Open anashasabelnabi opened 4 years ago

anashasabelnabi commented 4 years ago

i already do all of this tutorial but when i need to get uploaded image an error occurred Call to a member function getBehavior() on null <?php foreach($model->getBehavior('galleryBehavior')->getImages() as $image) { echo Html::img($image->getUrl('medium')); } ?>

zxbodya commented 4 years ago

it is outside of the extension… - looks like the object on which you are trying to get behavior is null

anashasabelnabi commented 4 years ago

Error is done but still not printing anything i use foreach in index view of product controller which have model Product <?php

    foreach($model->getBehavior('galleryBehavior')->getImages() as $image) {
        echo Html::img($image->getUrl('medium'));
    }
    ?></b>
zxbodya commented 4 years ago

from my understanding of what is happening, it looks like $model is null in when trying to use in a view, probably there is something wrong in the controller when loading it

anashasabelnabi commented 4 years ago

Do you have zoom account ?

anashasabelnabi commented 4 years ago

Screenshot from 2020-03-19 18-02-26 Screenshot from 2020-03-19 18-02-03 Screenshot from 2020-03-19 18-01-36

anashasabelnabi commented 4 years ago

Controller , model , view to show uploaded image , view to upload image Screenshot from 2020-03-19 18-06-05