mrself/symfony-tree-form-type

Symfony package for tree form type

1.5.1 2021-01-15 16:00 UTC

This package is auto-updated.

Last update: 2021-01-15 16:01:16 UTC


README

Still under development!

Installing

composer require mrself/symfony-tree-form-type:^1.2.3

Make sure config/packages/twig.yaml has the following code:

twig:
    form_themes:
      - '@TreeType/tree_type.html.twig'

Assets

The main js asset is located here assets/dist/main.js. It should be required in your front-end bundle or just added to your html.

Usage

public function buildForm(\Symfony\Component\Form\FormBuilderInterface $builder, array $options)
{
    $builder->add('alternatives', MrTreeType::class, [
        'class' => DataClass::class,
        'tree' => [
            [
                'id' => '1',
                'text' => 'Item 1',
                'parent' => '#'
            ]
         ],
        'multiple' => true
    ]);
}