This forum has moved to a new location and is in read-only mode. Please visit talk.octobercms.com to access the new location.

Alexa94
Alexa94

I'm developing a plugin. There was a problem selecting a category. The binding table contains the following data:

category_id | product_id
1...........| 1
1...........| 2
1...........| 3

When I put a new product in a category already contains three products - there is this: http://imagizer.imageshack.us/a/img924/173/S5PXia.png

After storing duplicates disappear. It only appears when you create a new item, and if the product update - then everything works fine. Here are my sources:

product\config_relation.yaml

category:
    label: Category
    view:
        list: $/itdevelop/shop/models/category/columns.yaml
        toolbarButtons: add|remove
    manage:
        showSearch: true
        recordsPerPage: 10
        list: $/itdevelop/shop/models/category/columns.yaml

models\product\fields.yaml

fields:
    ..........
secondaryTabs:
    fields:
        description:
            label: 'itdevelop.shop::lang.product.description'
            size: large
            oc.commentPosition: ''
            span: full
            type: richeditor
            tab: 'itdevelop.shop::lang.product.tab_description'
        category:
            label: 'itdevelop.shop::lang.product.category'
            type: partial
            path: field_category
            tab: 'itdevelop.shop::lang.product.tab_category'

models\product.php

public $belongsToMany = [
    'category' => [
        'ITDevelop\Shop\Models\Category',
        'table' => 'itdevelop_shop_relation_category_product',
    ],
];

Tell me, what is the problem? Thank You!

Last updated

1-1 of 1

You cannot edit posts or make replies: the forum has moved to talk.octobercms.com.