deblan.io-murph/src/Form/ProjectType.php
Simon Vieille 798b66c96c
All checks were successful
ci/woodpecker/push/woodpecker Pipeline was successful
ci/woodpecker/deployment/woodpecker Pipeline was successful
fix constraints of file in project form
2023-03-09 23:00:01 +01:00

99 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' => true,
'data_class' => null,
'attr' => [
],
'constraints' => [
new NotBlank(),
],
]
);
$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,
]);
}
}