This form class is responsible for creating a category selector using a tree view

Type options

Option Type Default value Description
label boolean false
choices array
list array
valid_list array
multiple boolean true allows multi selection of categories

Required Javascript components

Component Description
../admin-dev/themes/default/js/bundle/category-tree.js Responsible for category tree expanding and collapsing interactivity

Code example

$builder->add('categories', ChoiceCategoriesTreeType::class, [
    'label' => $this->translator->trans('Associated categories', [], 'Admin.Catalog.Feature'),
    'list' => $this->nested_categories,
    'valid_list' => $this->categories,
    'multiple' => true,

Preview example

ChoiceCategoriesTreeType rendered in form example