123 lines
3.4 KiB
PHP
123 lines
3.4 KiB
PHP
|
<?php
|
||
|
|
||
|
namespace App\Form\Blog\Filter;
|
||
|
|
||
|
use App\Entity\Blog\Category;
|
||
|
use App\Entity\Blog\Post;
|
||
|
use App\Entity\User;
|
||
|
use Doctrine\ORM\EntityRepository;
|
||
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
||
|
use Symfony\Component\Form\AbstractType;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\DateType;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\FileType;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
||
|
use Symfony\Component\Form\FormBuilderInterface;
|
||
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
||
|
use Symfony\Component\Validator\Constraints\Date;
|
||
|
use Symfony\Component\Validator\Constraints\Image;
|
||
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\NumberType;
|
||
|
use Symfony\Component\Validator\Constraints\Range;
|
||
|
use Symfony\Component\Validator\Constraints\Url;
|
||
|
use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
|
||
|
|
||
|
class PostFilterType extends AbstractType
|
||
|
{
|
||
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
||
|
{
|
||
|
$builder->add(
|
||
|
'title',
|
||
|
TextType::class,
|
||
|
[
|
||
|
'label' => 'Titre',
|
||
|
'required' => false,
|
||
|
'attr' => [
|
||
|
],
|
||
|
'constraints' => [
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$builder->add(
|
||
|
'contentFormat',
|
||
|
ChoiceType::class,
|
||
|
[
|
||
|
'label' => 'Format',
|
||
|
'required' => false,
|
||
|
'choices' => [
|
||
|
'HTML' => 'html',
|
||
|
'Markdown' => 'markdown',
|
||
|
],
|
||
|
'constraints' => [
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$builder->add(
|
||
|
'category',
|
||
|
EntityType::class,
|
||
|
[
|
||
|
'label' => 'Catégories',
|
||
|
'class' => Category::class,
|
||
|
'choice_label' => 'title',
|
||
|
'required' => false,
|
||
|
'attr' => [
|
||
|
'data-jschoice' => '',
|
||
|
],
|
||
|
'query_builder' => function (EntityRepository $repo) {
|
||
|
return $repo->createQueryBuilder('a')
|
||
|
->orderBy('a.title', 'ASC')
|
||
|
;
|
||
|
},
|
||
|
'constraints' => [
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$builder->add(
|
||
|
'status',
|
||
|
ChoiceType::class,
|
||
|
[
|
||
|
'label' => 'Statut',
|
||
|
'required' => false,
|
||
|
'choices' => [
|
||
|
'Brouillon' => 0,
|
||
|
'Publié' => 1,
|
||
|
],
|
||
|
'attr' => [
|
||
|
],
|
||
|
'constraints' => [
|
||
|
],
|
||
|
]
|
||
|
);
|
||
|
|
||
|
$builder->add(
|
||
|
'isQuick',
|
||
|
ChoiceType::class,
|
||
|
[
|
||
|
'label' => 'Quick',
|
||
|
'required' => false,
|
||
|
'choices' => [
|
||
|
'Anyway' => null,
|
||
|
'Yes' => true,
|
||
|
'No' => false,
|
||
|
],
|
||
|
'attr' => [
|
||
|
],
|
||
|
'constraints' => [
|
||
|
]
|
||
|
]
|
||
|
);
|
||
|
}
|
||
|
|
||
|
public function configureOptions(OptionsResolver $resolver)
|
||
|
{
|
||
|
$resolver->setDefaults([
|
||
|
'data_class' => null,
|
||
|
'csrf_protection' => false,
|
||
|
]);
|
||
|
}
|
||
|
}
|