87 lines
2.2 KiB
PHP
87 lines
2.2 KiB
PHP
<?php
|
|
|
|
namespace App\Form\Blog\Filter;
|
|
|
|
use Doctrine\ORM\EntityRepository;
|
|
use Symfony\Bridge\Doctrine\Form\Type\EntityType;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use App\Entity\Blog\Post;
|
|
use Symfony\Component\Form\ChoiceList\ChoiceList;
|
|
|
|
class CommentFilterType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$builder->add(
|
|
'author',
|
|
TextType::class,
|
|
[
|
|
'required' => false,
|
|
'label' => 'Auteur',
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'website',
|
|
TextType::class,
|
|
[
|
|
'required' => false,
|
|
'label' => 'Site web',
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'email',
|
|
TextType::class,
|
|
[
|
|
'label' => 'E-mail (non publié)',
|
|
'required' => false,
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'post',
|
|
EntityType::class,
|
|
[
|
|
'label' => 'Article',
|
|
'class' => Post::class,
|
|
'choice_label' => 'title',
|
|
'choice_value' => 'id',
|
|
'required' => false,
|
|
'attr' => [
|
|
],
|
|
'query_builder' => function (EntityRepository $repo) {
|
|
return $repo->createQueryBuilder('p')
|
|
->orderBy('p.id', 'DESC')
|
|
;
|
|
},
|
|
'constraints' => [
|
|
],
|
|
]
|
|
);
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => null,
|
|
'csrf_protection' => false,
|
|
]);
|
|
}
|
|
}
|