73 lines
1.8 KiB
PHP
73 lines
1.8 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Form\Site;
|
||
|
|
||
|
use App\Entity\Site\Node;
|
||
|
use Symfony\Component\Form\AbstractType;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||
|
|
||
|
class NodeType extends AbstractType
|
||
|
{
|
||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||
|
{
|
||
|
$builder->add(
|
||
|
'label',
|
||
|
TextType::class,
|
||
|
[
|
||
|
'label' => 'Libellé',
|
||
|
'required' => true,
|
||
|
'attr' => [
|
||
|
],
|
||
|
'constraints' => [
|
||
|
new NotBlank(),
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$builder->add(
|
||
|
'url',
|
||
|
TextType::class,
|
||
|
[
|
||
|
'label' => 'URL',
|
||
|
'required' => false,
|
||
|
'help' => 'Laisser vide pour une génération automatique',
|
||
|
'attr' => [
|
||
|
],
|
||
|
'constraints' => [
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$builder->add(
|
||
|
'position',
|
||
|
ChoiceType::class,
|
||
|
[
|
||
|
'label' => 'Position',
|
||
|
'required' => true,
|
||
|
'mapped' => false,
|
||
|
'choices' => [
|
||
|
'Après' => 'after',
|
||
|
'Avant' => 'before',
|
||
|
'En dessous' => 'above',
|
||
|
],
|
||
|
'attr' => [
|
||
|
],
|
||
|
'constraints' => [
|
||
|
new NotBlank(),
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function configureOptions(OptionsResolver $resolver)
|
||
|
{
|
||
|
$resolver->setDefaults([
|
||
|
'data_class' => Node::class,
|
||
|
]);
|
||
|
}
|
||
|
}
|