yii-dream-team / yii2-upload-behavior

Yii2 file/image upload behavior for ActiveRecord
http://yiidreamteam.com/yii2/upload-behavior
MIT License
77 stars 45 forks source link

Missing behavior for attribute 'file' #4

Closed timmy78 closed 9 years ago

timmy78 commented 9 years ago

See #3

I have the to types of behaviors (ImageUploadBehavior & FileUploadBehavior) in my model :

'image-upload' => [
    'class' => '\yiidreamteam\upload\ImageUploadBehavior',
    'attribute' => 'image',
    'filePath' => '@webroot/images/[[model]]/[[pk]]/[[basename]]',
    'fileUrl' => '@web/images/[[model]]/[[pk]]/[[basename]]',
],
'file-upload' => [
    'class' => '\yiidreamteam\upload\FileUploadBehavior',
    'attribute' => 'file',
    'filePath' => '@webroot/[[model]]/[[pk]]/[[basename]]',
    'fileUrl' => '@web/[[model]]/[[pk]]/[[basename]]',
],

But when want to access to my second attribute file with getUploadFilePath('file'), it returns me an error : Missing behavior for attribute 'file'. When I var_dump the current behavior class, in FileUploadBehavior, it says that file is an instance of ImageUploadBehavior which is incorrect. When I change $behavior instanceof static to $behavior instanceof self it works.

So the problem comes when in the model behaviors function the two types are declared ;)

Thank you !

metalagman commented 9 years ago

thank you for your feedback, fixed!