There is an entity that has a tree implemented by specifying the parent.
// ... class Folder { /** * @ORM \ManyToOne(targetEntity="Folder") * @ORM \JoinColumn(name="pid", referencedColumnName="id") */ protected $parent; // ... }
The form is made like this:
$builder->add('parent', 'entity', array( 'class' => 'MyBundle:Folder', ))
In this case, the list of "Folders" turns out to be "flat", from a simple maximum that can be done to describe it in the query_builder form builder and sort it by some field ...
Required : display a list of "folders" in the tree view. for example, now the list of all folders will look something like this:
Folder1 Folder2 Folder3 Folder4
but should like this:
Folder1 Folder4 Folder3 Folder2
those. there will be the same select option, but in a special order in accordance with the parent-child hierarchy, also inside the option add a couple of spaces for visual indentation.
The second task is more complicated : it would be very convenient to say, when editing Folder4 in the list, Folder3 is displayed as inactive. you can’t ask your baby as a parent :) well, and the third question: how to check this moment while saving?