So you think this isn’t a standard behavior and could not happen?
Just wanna add that when I select a Model View I can’t select it anymore from the list (disappears) so it’s totally intended behavior.
I’m running 3.5.5.
Here’s the configuration
Domain Model
public $belongsToMany = [
'views' => [
\qbut\manager\Models\View::class,
'table' => 'qbut_manager_domain_view',
'pivot' => ['position', 'position_detail', 'active'],
'pivotSortable' => 'sorting',
'timestamps' => true
]
];
View Model
No relation definition
Domain View Model
public $belongsTo = [
'domain' => [
\qbut\manager\Models\Domain::class,
],
'view' => [
\qbut\manager\Models\View::class,
],
];
Domain Controller
class Domain extends Controller
{
public $implement = [ 'Backend\Behaviors\ListController', 'Backend\Behaviors\FormController', 'Backend\Behaviors\RelationController' ];
public $listConfig = 'config_list.yaml';
public $formConfig = 'config_form.yaml';
public $relationConfig = 'config_relation.yaml';
}
Domain config_relation.yaml
views:
structure:
showReorder: true
showTree: false
label: Views
view:
list:
columns:
name:
label: Name
pivot[position]:
label: Position
type: text
pivot[position_detail]:
label: Position detail
type: text
pivot[active]:
label: Active
type: switch
manage:
list: $/qbut/manager/models/view/columns.yaml
pivot:
form:
fields:
name:
label: Name
disabled: true
pivot[position]:
label: Position
span: full
type: text
default: head
pivot[position_detail]:
label: Position detail
span: full
type: dropdown
options:
prepend: prepend
append: append
pivot[active]:
label: Active
default: 1
span: left
type: checkbox
Schemas
mysql> describe qbut_manager_domain;
+-------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-------------+--------------+------+-----+---------+----------------+
| id | int unsigned | NO | PRI | NULL | auto_increment |
| domain_name | varchar(255) | NO | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
+-------------+--------------+------+-----+---------+----------------+
mysql> describe qbut_manager_domain_view; (intermediate)
+-----------------+--------------------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------------------+------+-----+---------+----------------+
| position | varchar(255) | NO | | head | |
| active | tinyint(1) | NO | | 1 | |
| sorting | int | YES | | NULL | |
| view_id | int | NO | | NULL | |
| domain_id | int | NO | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
| id | int unsigned | NO | PRI | NULL | auto_increment |
| position_detail | enum('prepend','append') | NO | | prepend | |
+-----------------+--------------------------+------+-----+---------+----------------+
mysql> describe qbut_manager_view;
+-----------------+--------------+------+-----+---------+----------------+
| Field | Type | Null | Key | Default | Extra |
+-----------------+--------------+------+-----+---------+----------------+
| id | int unsigned | NO | PRI | NULL | auto_increment |
| name | varchar(255) | NO | | NULL | |
| filename | varchar(255) | NO | | NULL | |
| created_at | timestamp | YES | | NULL | |
| updated_at | timestamp | YES | | NULL | |
| category_id | int | YES | | NULL | |
| is_cookiebanner | tinyint(1) | NO | | 0 | |
| auto_create | tinyint(1) | NO | | 0 | |
+-----------------+--------------+------+-----+---------+----------------+