diiimonn / yii2-behavior-relation-follow
Installs: 79
Dependents: 0
Suggesters: 0
Security: 0
Stars: 0
Watchers: 2
Forks: 1
Open Issues: 0
Type:yii2-extension
This package is not auto-updated.
Last update: 2025-04-26 19:51:41 UTC
README
Model behavior for relation data management
Installation
To install with composer:
$ php composer.phar require diiimonn/yii2-behavior-relation-follow "dev-master"
or add
"diiimonn/yii2-behavior-relation-follow": "dev-master"
to the require
section of your composer.json
file.
Usage
in MyModel.php
... use diiimonn\behaviors\RelationFollowBehavior; ... public function behaviors() { return [ ... [ 'class' => RelationFollowBehavior::className(), 'relations' => [ 'books', // relation name ] ], ]; } public function getBooks() { return $this->hasMany(BookModel::className(), ['id' => 'book_id'])->via('authorBooks'); } public function getAuthorBooks() { return $this->hasMany(AuthorBooks::className(), ['author_id' => 'id']); } ...
in my-view/_form.php
Select multiple from relation model. Recommended use yii2-widget-checkbox-multiple