Hi! I created a Categories model with a Nested Tree trait. I need to be able to select multiple categories in Products model.
I added belongsToMany in Products model:
public $belongsToMany = [
'categories' => [
Categories::class,
'table' => 'my_products_products_categories',
'order' => 'name'
],
];
and field in Product model:
categories:
label: 'Select categories'
nameFrom: name
descriptionFrom: description
span: auto
type: partial
path: $/my/products/controllers/products/_categories_field.php
In the relationship configuration file I added:
categories:
label: 'Categories'
view:
list:
columns:
name:
label: 'Name'
type: text
toolbarButtons: add|remove
manage:
list: $/my/products/models/categories/columns.yaml
form: $/my/products/models/categories/fields.yaml
showSearch: true
How to display categories list in the tree view?
Adding this in config_relation.yaml doesn’t work:
structure:
showTree: true