94 lines
2.4 KiB
PHP
94 lines
2.4 KiB
PHP
<?php
|
|
|
|
namespace App\Form\Blog;
|
|
|
|
use App\Entity\Blog\Comment;
|
|
use Symfony\Component\Form\AbstractType;
|
|
use Symfony\Component\Form\Extension\Core\Type\EmailType;
|
|
use Symfony\Component\Form\Extension\Core\Type\HiddenType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextareaType;
|
|
use Symfony\Component\Form\Extension\Core\Type\TextType;
|
|
use Symfony\Component\Form\Extension\Core\Type\UrlType;
|
|
use Symfony\Component\Form\FormBuilderInterface;
|
|
use Symfony\Component\OptionsResolver\OptionsResolver;
|
|
use Symfony\Component\Validator\Constraints\Email;
|
|
use Symfony\Component\Validator\Constraints\NotBlank;
|
|
use Symfony\Component\Validator\Constraints\Url;
|
|
|
|
class UserCommentType extends AbstractType
|
|
{
|
|
public function buildForm(FormBuilderInterface $builder, array $options)
|
|
{
|
|
$builder->add(
|
|
'author',
|
|
TextType::class,
|
|
[
|
|
'required' => true,
|
|
'label' => 'Auteur',
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
new NotBlank(),
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'website',
|
|
UrlType::class,
|
|
[
|
|
'required' => false,
|
|
'label' => 'Site web',
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
new Url(),
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'email',
|
|
EmailType::class,
|
|
[
|
|
'label' => 'E-mail (non publié)',
|
|
'required' => false,
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
new Email(),
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'content',
|
|
TextareaType::class,
|
|
[
|
|
'label' => 'Commentaire',
|
|
'required' => true,
|
|
'attr' => [
|
|
],
|
|
'constraints' => [
|
|
new NotBlank(),
|
|
],
|
|
]
|
|
);
|
|
|
|
$builder->add(
|
|
'parentCommentId',
|
|
HiddenType::class,
|
|
[
|
|
'mapped' => false,
|
|
]
|
|
);
|
|
}
|
|
|
|
public function configureOptions(OptionsResolver $resolver)
|
|
{
|
|
$resolver->setDefaults([
|
|
'data_class' => Comment::class,
|
|
]);
|
|
}
|
|
}
|