<?php
|
|
|
|
namespace App\Form;
|
|
|
|
use App\Entity\Project;
|
|
use App\Entity\Tag;
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
|
|
class ProjectType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
{
|
|
$builder
|
|
->add('name', null, ['label' => 'Nom'])
|
|
->add('description', null, ['label' => 'Description'])
|
|
->add('tags', EntityType::class, [
|
|
'label' => 'Étiquettes',
|
|
'class' => Tag::class,
|
|
'choice_label' => 'name',
|
|
'multiple' => true,
|
|
'expanded' => true,
|
|
])
|
|
;
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver): void
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => Project::class,
|
|
]);
|
|
}
|
|
}
|