PHP code example of yavin / symfony-form-tree

1. Go to this page and download the library: Download yavin/symfony-form-tree library. Choose the download type require.

2. Extract the ZIP file and open the index.php.

3. Add this code to the index.php.
    
        
<?php
require_once('vendor/autoload.php');

/* Start to develop here. Best regards https://php-download.com/ */

    

yavin / symfony-form-tree example snippets


    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',
        ]);
    }