Tell me how you can implement the grouping of elements in the ObjectSelect ' optgroup_identifier ' drop-down list (groups by field in the Example table)
Form\CategoryForm.php
$this->add([ 'type' => ObjectSelect::class, 'name' => 'category', 'options' => [ 'label' => 'Категория', 'object_manager' => $this->getObjectManager(), 'target_class' => Category::class, 'property' => 'name', 'optgroup_identifier' => '???', 'optgroup_default' => 'Главная', 'empty_option' => '== Категория ==', 'is_method' => true, 'find_method' => [ 'name' => 'findAllChildCategories', 'params' => [ ], ], ]); The category table is self-referencing
Entity\Category.php
/** * @var \Doctrine\Common\Collections\Collection * * @ORM\OneToMany(targetEntity="Application\Entity\Category", mappedBy="parent", cascade={"remove"}) */ private $children; /** * @var \Application\Entity\Category * * @ORM\ManyToOne(targetEntity="Application\Entity\Category", inversedBy="children") * @ORM\JoinColumns({ * @ORM\JoinColumn(name="parent", referencedColumnName="id", nullable=true) * }) */ private $parent; Group names should be parental categories.
$category->getParent()->getName()
