2017 © Pedro Peláez
 

library symfony-form-tree

create select field with indentation for tree structure

image

yavin/symfony-form-tree

create select field with indentation for tree structure

  • Saturday, February 11, 2017
  • by Yavin
  • Repository
  • 1 Watchers
  • 14 Stars
  • 26,011 Installations
  • PHP
  • 2 Dependents
  • 0 Suggesters
  • 3 Forks
  • 1 Open issues
  • 10 Versions
  • 9 % Grown

The README.md

Symfony Form Tree extension

Build Status, (*1)

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., (*2)

It is tested and should work with symfony 3.0+, (*3)

If want to use this in symfony 2 look at "symfony-2" branch of this extension, (*4)

, (*5)

<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, (*6)

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

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

    or if you use yml format:, (*8)

    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, (*9)

    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., (*10)

    Here is example tree entity., (*11)

Other

License

MIT, (*12)

The Versions

11/02 2017

dev-master

9999999-dev

create select field with indentation for tree structure

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Yavin

11/02 2017

v1.0.2

1.0.2.0

create select field with indentation for tree structure

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Yavin

11/02 2017

dev-test

dev-test

create select field with indentation for tree structure

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Yavin

04/12 2016

v1.0.1

1.0.1.0

create select field with indentation for tree structure

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Yavin

17/01 2016

dev-symfony-2

dev-symfony-2

create select field with indentation for tree structure

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Yavin

17/01 2016
17/01 2016

v1.0.0

1.0.0.0

create select field with indentation for tree structure

  Sources   Download

MIT

The Requires

 

The Development Requires

by Avatar Yavin

15/11 2015