63 lines
1.7 KiB
PHP
63 lines
1.7 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Form\Site;
|
||
|
|
||
|
use App\Entity\Site\Node;
|
||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||
|
use Symfony\Component\Form\AbstractType;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||
|
|
||
|
class NodeMoveType extends AbstractType
|
||
|
{
|
||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||
|
{
|
||
|
$builder->add(
|
||
|
'position',
|
||
|
ChoiceType::class,
|
||
|
[
|
||
|
'label' => 'Position',
|
||
|
'required' => true,
|
||
|
'choices' => [
|
||
|
'Après' => 'after',
|
||
|
'Avant' => 'before',
|
||
|
'En dessous' => 'above',
|
||
|
],
|
||
|
'attr' => [
|
||
|
],
|
||
|
'constraints' => [
|
||
|
new NotBlank(),
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$builder->add(
|
||
|
'node',
|
||
|
EntityType::class,
|
||
|
[
|
||
|
'label' => 'Élement de référence',
|
||
|
'class' => Node::class,
|
||
|
'choices' => call_user_func(function () use ($options) {
|
||
|
return $options['menu']->getRootNode()->getAllChildren();
|
||
|
}),
|
||
|
'choice_label' => 'treeLabel',
|
||
|
'attr' => [
|
||
|
],
|
||
|
'constraints' => [
|
||
|
new NotBlank(),
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function configureOptions(OptionsResolver $resolver)
|
||
|
{
|
||
|
$resolver->setDefaults([
|
||
|
'data_class' => null,
|
||
|
'menu' => null,
|
||
|
]);
|
||
|
}
|
||
|
}
|