GitHub - Yavin/symfony-form-tree: Symfony Form Tree type | Latest TMZ Celebrity News & Gossip | Watch TMZ Live
Skip to content

Yavin/symfony-form-tree

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

14 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Symfony Form Tree extension

Build Status

This extension provide displaying doctrine tree entity types in synfony forms. It add a prefix to option names in select list that indicates tree level.

It is tested and should work with symfony 3.0+

If want to use this in symfony 2 look at "symfony-2" branch of this extension

<select name="..." data-level-prefix="-">
    <option value="1">Motors</option>
    <option value="2">Electronics</option>
    <option value="3">-Cell phones</option>
    <option value="4">--Samsung</option>
    <option value="5">-Computers</option>
    <option value="6">Fasion</option>
</select>

Instalation

  1. With composer.json

    composer require yavin/symfony-form-tree:^1.0
    
  2. Add type guesser in your services file (optional):

    <service class="Yavin\Symfony\Form\Type\TreeTypeGuesser">
        <argument type="service" id="doctrine"/>
        <tag name="form.type_guesser"/>
    </service>

    or if you use yml format:

    services:
        symfony.form.type_guesser.tree:
            class: Yavin\Symfony\Form\Type\TreeTypeGuesser
            arguments: [ "@doctrine" ]
            tags:
                - { name: form.type_guesser }
  3. Then add field to tree model. In this example

    use Yavin\Symfony\Form\Type\TreeType;
    
    public function buildForm(FormBuilderInterface $builder, array $options)
    {
        $builder->add('category'); //extension will guess field type
    
        //or this is full example with default options:
    
        $builder->add('category', TreeType::class, [
            'class' => Category::class, // tree class
            'levelPrefix' => '-',
            'orderFields' => ['treeLeft' => 'asc'],
            'prefixAttributeName' => 'data-level-prefix',
            'treeLevelField' => 'treeLevel',
        ]);
    }

    This extension assume that in tree model You have treeLeft and treeLevel fields. It can be changed in field options.

    Here is example tree entity.

Other

License

MIT

About

Symfony Form Tree type

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Contributors 3

  •  
  •  
  •  

Languages

TMZ Celebrity News – Breaking Stories, Videos & Gossip

Looking for the latest TMZ celebrity news? You've come to the right place. From shocking Hollywood scandals to exclusive videos, TMZ delivers it all in real time.

Whether it’s a red carpet slip-up, a viral paparazzi moment, or a legal drama involving your favorite stars, TMZ news is always first to break the story. Stay in the loop with daily updates, insider tips, and jaw-dropping photos.

🎥 Watch TMZ Live

TMZ Live brings you daily celebrity news and interviews straight from the TMZ newsroom. Don’t miss a beat—watch now and see what’s trending in Hollywood.