src/Form/Type/PostFormType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form\Type;
  3. use App\Entity\Post;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  6. use Symfony\Component\Form\Extension\Core\Type\TextType;
  7. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. class PostFormType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options)
  13.     {
  14.         $builder
  15.             ->add('title'TextType::class)
  16.             ->add('thumbnail'TextType::class)
  17.             ->add('video'TextType::class)
  18.             ->add('excerpt'TextType::class)
  19.             ->add('notification'CheckboxType::class,[
  20.                 'mapped'=>false
  21.             ])
  22.             ->add('contents'CollectionType::class, [
  23.                 'entry_type' => PostContentFormType::class,
  24.                 'allow_add' => true,
  25.                 'allow_delete' => true,
  26.                 'by_reference' => false,
  27.             ])
  28.         ;
  29.     }
  30.     public function configureOptions(OptionsResolver $resolver)
  31.     {
  32.         $resolver->setDefaults([
  33.             'csrf_protection' => false,
  34.             'data_class' => Post::class,
  35.         ]);
  36.     }
  37. }