October cms User plugin many-to-many relation

669 views Asked by At

Having the following table structure

user
| id | name |

class
| id | name |

users_classes
   | user_id | class_id | value |

I have built many to many relationship with belongsToMany User.php

public $belongsToMany = [
        'groups' => [UserGroup::class, 'table' => 'users_groups'],
        'classes' => [UserClass::class,
            'table' => 'users_classes',
            'key'=>'user_id',
            ],
    ];

UserClass.php

public $belongsToMany = [
        'users' => [User::class,
            'table' => 'users_classes',
            'key'=>'class_id']
    ];

And also in rainlab\user\models\user\fields.yaml

classes: label: class type: relation

I can add user_id and class_id in users_classes But I can't see VALUE field in backend form? How can I add users_classes.value field to admin form and add some value in it?

0

There are 0 answers