I have a serious doubt that you are making a combo box with nested entries from an object in Symfony2. I read about the nested tree extension for Doctrine 2 at http://gediminasm.org/article/tree-nestedset-behavior-extension-for-doctrine-2 , it seems interesting, but it does not specify how to implement this nested tree in the field object in shape.
In addition, I read more about recursive functions in PHP, and I found an interesting blog where it is analyzed, here is the link http://www.sitepoint.com/hierarchical-data-database/ , it specifically explains this recursive function:
function display_children($parent, $level) { // Retrieve all children of $parent $result = mysql_query('SELECT title FROM tree WHERE parent="'.$parent.'"'); // Display each child while ($row = mysql_fetch_array($result)) { // Indent and display the title of this child echo str_repeat(' ',$level).$row['title']."\n"; // Call this function again to display this child children display_children($row['title'], $level+1); } }
Someone knows how to translate this code into Symfony2 and where it will be stored (Controller, Entity, etc.). If anyone has any other ideas on working with nested posts with Twig Extensions, it would also be helpful.
Many thanks for your help.
source share