Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7663945
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 31, 20262026-05-31T14:10:38+00:00 2026-05-31T14:10:38+00:00

I have a Categories table, built with Tree architecture, using Doctrine Tree Extension and

  • 0

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
864 (NULL)  Movies  1   0   18  864
865 864 Packs   2   1   3   864
866 864 Dubbed  4   1   5   864

and visually like this:

Movies
|
|
|->Packs
|->Dubbed

now i want to generated form for adding reviews , and loading categories as dropdown list for each movie, so i have in my movie-review form-type-class

public function buildForm(FormBuilder $builder, array $options)
{

    $builder->add('name');
    $builder->add('file');
    $builder->add('cover');
    $builder->add('category','entity',           array('class'=>'Tracker\MembersBundle\Entity\Category', 'property'=>'title', ));           
}

which generates a normal dropdown menu like this:

enter image description here

how can i configure my menu settings, so it generates a Tree-Like-dropdown select like this?

enter image description here

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-31T14:10:40+00:00Added an answer on May 31, 2026 at 2:10 pm

    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

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a categories table that looks like this: id | name | parent
Greetings, fellow coders! I have this table that contains categories and subcategories (actually I
I have a tree (nested categories) stored as follows: CREATE TABLE `category` ( `category_id`
I have 7 column in my table users. The columns are like this: ac0
I have a Categories table in which each category has a ParentId that can
I have a categories table, which one of the fields serves as the foreign
I have a table named categories, which contains ID(long), Name(varchar(50)), parentID(long), and shownByDefault(boolean) columns.
I have a table of categories. Each category can either be a root level
I have a self referencing table named categories that has a parentcategoryid column that
Greetings - I have a table of Articles and a table of Categories. An

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.