You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

72 lines
2.0KB

  1. <?php
  2. namespace App\Type;
  3. use App\Entity\ProjectsInspiring;
  4. use App\Entity\Thematic;
  5. use Lc\SovBundle\Doctrine\EntityManager;
  6. use Lc\SovBundle\Model\User\UserInterface;
  7. use Lc\SovBundle\Translation\TranslatorAdmin;
  8. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  9. use Symfony\Component\Form\AbstractType;
  10. use Symfony\Component\Form\Extension\Core\Type\PasswordType;
  11. use Symfony\Component\Form\Extension\Core\Type\RepeatedType;
  12. use Symfony\Component\Form\Extension\Core\Type\SubmitType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  14. use Symfony\Component\Form\FormBuilderInterface;
  15. use Symfony\Component\OptionsResolver\OptionsResolver;
  16. use Symfony\Component\Security\Core\Validator\Constraints\UserPassword;
  17. use Symfony\Component\Validator\Constraints\NotBlank;
  18. class ProjectsInspiringType extends AbstractType
  19. {
  20. protected $em;
  21. protected $translatorAdmin;
  22. public function __construct(EntityManager $em, TranslatorAdmin $translatorAdmin)
  23. {
  24. $this->em = $em;
  25. $this->translatorAdmin = $translatorAdmin;
  26. }
  27. /**
  28. * {@inheritdoc}
  29. */
  30. public function buildForm(FormBuilderInterface $builder, array $options)
  31. {
  32. $builder->add(
  33. 'description',
  34. TextareaType::class,
  35. [
  36. 'label' => 'form.field.projectsinspiring.description',
  37. 'constraints' => [
  38. new NotBlank(),
  39. ],
  40. ]
  41. )
  42. ->add(
  43. 'thematic',
  44. EntityType::class,
  45. [
  46. 'label' => 'form.field.projectsinspiring.thematic',
  47. 'class' => Thematic::class,
  48. 'required' => false,
  49. ]
  50. );
  51. }
  52. /**
  53. * {@inheritdoc}
  54. */
  55. public function configureOptions(OptionsResolver $resolver)
  56. {
  57. $resolver->setDefaults(
  58. [
  59. 'data_class' => $this->em->getEntityName(ProjectsInspiring::class),
  60. ]
  61. );
  62. }
  63. }