98 lines
2.5 KiB
PHP
98 lines
2.5 KiB
PHP
<?php
|
|
|
|
namespace App\Form;
|
|
|
|
use App\Core\Form\FileManager\FilePickerType;
|
|
use App\Core\Form\Type\CollectionType;
|
|
use App\Entity\Project;
|
|
use App\Form\Type\SimpleMdTextareaType;
|
|
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 ProjectType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options): void
|
|
{
|
|
$builder->add(
|
|
'label',
|
|
TextType::class,
|
|
[
|
|
'label' => 'Libellé',
|
|
'required' => true,
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
new NotBlank(),
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'status',
|
|
ChoiceType::class,
|
|
[
|
|
'label' => 'Statut',
|
|
'required' => true,
|
|
'choices' => [
|
|
'Brouillon' => Project::DRAFT,
|
|
'Publié' => Project::PUBLISHED,
|
|
],
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
new NotBlank(),
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'description',
|
|
SimpleMdTextareaType::class,
|
|
[
|
|
'label' => 'Contenu',
|
|
'required' => false,
|
|
'constraints' => [
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'image',
|
|
FilePickerType::class,
|
|
[
|
|
'label' => 'Image',
|
|
'required' => false,
|
|
'data_class' => null,
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'links',
|
|
CollectionType::class,
|
|
[
|
|
'label' => 'Liens',
|
|
'entry_type' => ProjectLinkType::class,
|
|
'by_reference' => false,
|
|
'allow_add' => true,
|
|
'allow_delete' => true,
|
|
'prototype' => true,
|
|
]
|
|
);
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver): void
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => Project::class,
|
|
]);
|
|
}
|
|
}
|