Open kishor10d opened 7 years ago
I have that scenario constantly and that should be done with the provided FileUploadAction: https://github.com/2amigos/yii2-file-upload-widget/blob/master/src/actions/FileUploadAction.php#L136
As you can see on that line, the OwnerId its retrieved by a parameter: https://github.com/2amigos/yii2-file-upload-widget/blob/master/src/actions/FileUploadAction.php#L106 and the function LINK: https://github.com/2amigos/yii2-file-upload-widget/blob/master/src/actions/FileUploadAction.php#L168 is the one in charge to create the relation. On your example, I would create the tables like this: Product(id, name), Image(id, path), ProductImageAssn(prodId, imageId)
so the ProductImageAssn
is the ownerLinkTableAttribute
on the Action.
Check careful that action class, because all the answers are there. If you have issues, I'll elaborate an example whenever I have some free time.
Hello, Suppose I have a two tables,
Products
andProductImages
When I am going to create product, I have to upload images as well, and id of Product will be used as foreign key in ProductImages.Product(id, prodname)
ProductImages(imgid, id, imagePath)
One product has many images. First create a Product, then upload the images. After that refer product id as foreign key and then insert all imagePaths in ProductImages table.
How to achieve this scenario using this plugin. Can you setup any example for this? Please, it will helpful for all.