52 lines
1.6 KiB
PHP
52 lines
1.6 KiB
PHP
<?php
|
|
|
|
namespace App\Form;
|
|
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\Extension\Core\Type\SubmitType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Tetranz\Select2EntityBundle\Form\Type\Select2EntityType;
|
|
|
|
class TagType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$builder
|
|
->add('submit', SubmitType::class, [
|
|
'label' => 'Valider',
|
|
'attr' => ['class' => 'btn btn-success'],
|
|
])
|
|
|
|
->add('id', TextType::class, [
|
|
'label' => 'Tag',
|
|
])
|
|
|
|
->add('childs', Select2EntityType::class, [
|
|
'label' => 'Lié aux childs',
|
|
'class' => 'App:Child',
|
|
'multiple' => true,
|
|
'remote_route' => 'app_child_select',
|
|
'primary_key' => 'id',
|
|
'text_property' => 'name',
|
|
'minimum_input_length' => 0,
|
|
'page_limit' => 100,
|
|
'allow_clear' => true,
|
|
'delay' => 250,
|
|
'cache' => false,
|
|
'cache_timeout' => 60000,
|
|
'language' => 'fr',
|
|
'placeholder' => 'Selectionner des childs',
|
|
]);
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => 'App\Entity\Tag',
|
|
'mode' => 'string',
|
|
]);
|
|
}
|
|
}
|