src/Form/BackOffice/MessageType.php line 16

Open in your IDE?
  1. <?php
  2. namespace App\Form\BackOffice;
  3. use App\Entity\Message;
  4. use App\Form\ApplicationType\BackOffice;
  5. use Symfony\Component\Form\AbstractType;
  6. use FOS\CKEditorBundle\Form\Type\CKEditorType;
  7. use Symfony\Component\Form\FormBuilderInterface;
  8. use Symfony\Component\OptionsResolver\OptionsResolver;
  9. use Symfony\Component\Form\Extension\Core\Type\FileType;
  10. use Symfony\Component\Form\Extension\Core\Type\TextType;
  11. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  12. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  13. class MessageType extends ApplicationType
  14. {
  15.  /**
  16.      * permet d'avoir la configuration de base d'un champ !
  17.      * 
  18.      * @param string $label
  19.      * @param string $placeholder
  20.      * @return array
  21.      */
  22.     protected function getConfiguration($label$placeholder)
  23.     {
  24.         return[
  25.            'label' => $label,
  26.             'attr' => [
  27.                 'placeholder' => $placeholder
  28.             ]
  29.         ];
  30.     }    
  31.     public function buildForm(FormBuilderInterface $builder, array $options): void
  32.     {
  33.         $builder
  34.         ->add('nom',TextType::class, $this->getConfiguration(false"Nom..."))
  35.         ->add('prenom',TextType::class, $this->getConfiguration(false"Prénom(s)..."))
  36.         ->add('telephone',TextType::class, $this->getConfiguration(false"Téléphone..."))
  37.         ->add('email',EmailType::class, $this->getConfiguration(false"E-mail..."))
  38.         ->add('adresse',TextType::class, $this->getConfiguration(false"Adresse..."))
  39.         ->add('message',CKEditorType::class, $this->getConfiguration(false"Message..."));
  40.     }
  41.     public function configureOptions(OptionsResolver $resolver): void
  42.     {
  43.         $resolver->setDefaults([
  44.             'data_class' => Message::class,
  45.         ]);
  46.     }
  47. }