I have a Categories table, built with Tree architecture, using Doctrine Tree Extension and it looks something like this
id parent_id title lft lvl rgt root
I'm not sure this is a good idea : users won't be able to type in their choice.
Haven't tested this solution, but it should work :
First, you can sort the three by root and lft value to display it properly, so add a query builder:
'query_builder' => function($er) {
return $er->createQueryBuilder('c')
->orderBy('c.root', 'ASC')
->addOrderBy('c.lft', 'ASC');
},
Then, you need to add a getIndentedTitle
method to your entity:
public function getIndentedTitle() {
return str_repeat("--", $this->lvl).$this->title;
}
Finally, add a property option to your options when you build the form, to display the virtual property indentedTitle instead of title :
'property' => 'indentedTitle'
See : http://symfony.com/doc/current/reference/forms/types/entity.html