vendor/uvdesk/support-center-bundle/Form/Ticket.php line 27

Open in your IDE?
  1. <?php 
  2. namespace Webkul\UVDesk\SupportCenterBundle\Form;
  3. use Symfony\Component\Form\FormBuilderInterface;
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\OptionsResolver\OptionsResolver;
  6. use Symfony\Component\Validator\Constraints\Length;
  7. use Symfony\Component\Validator\Constraints\NotBlank;
  8. use Symfony\Component\Validator\Constraints\Email;
  9. use Symfony\Component\Validator\Constraints\RequiredReply;
  10. use Symfony\Component\Form\Extension\Core\Type\EmailType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  12. use Symfony\Component\Form\Extension\Core\Type\FileType;
  13. use Symfony\Bridge\Doctrine\Form\Type\EntityType;
  14. use Symfony\Component\Form\Extension\Core\Type;
  15. use Symfony\Component\Form\FormEvents;
  16. use Symfony\Component\Form\FormEvent;
  17. use Symfony\Component\Form\FormError;
  18. use Doctrine\ORM\EntityRepository;
  19. use Webkul\UVDesk\CoreFrameworkBundle\Entity as CoreEntites;
  20. class Ticket extends AbstractType
  21. {   
  22.     /**
  23.      * {@inheritdoc}
  24.      */
  25.     public function buildForm(FormBuilderInterface $builder, array $options)
  26.     {
  27.         $container $options['container'];
  28.         $entityManager $options['entity_manager'];
  29.         if(!is_object($container->get('user.service')->getSessionUser()) || $container->get('user.service')->getSessionUser() == 'anon.') {
  30.             $builder->add('name'null, [
  31.                 'required' => true,
  32.                 'label' => 'Your Name',
  33.                 'attr' => array('placeholder' => 'Enter Your Name'),
  34.                 'mapped' => false,
  35.             ]);
  36.             $builder->add('from'EmailType::class, array(
  37.                 'required' => true,
  38.                 'label' => 'Your Email',
  39.                 'mapped' => false,
  40.                 'attr' => array('placeholder' => 'Enter Your Email'),
  41.             ));
  42.         }
  43.         $builder->add('type'EntityType::class, array(
  44.             'class' => CoreEntites\TicketType::class,
  45.             'choice_label' => 'description',
  46.             'multiple' => false,
  47.             'mapped' => false,
  48.             'attr' => array(
  49.                     'data-role' => 'tagsinput',
  50.                     'data-live-search' => true,
  51.                     'class' => 'selectpicker'
  52.             ),
  53.             'query_builder' => function (EntityRepository $er) {
  54.                     return $er->createQueryBuilder('type')
  55.                                 ->andwhere('type.isActive = :isActive')->setParameter('isActive'true)
  56.                                 ->orderBy('type.description''ASC');
  57.             },
  58.             'placeholder' => 'Choose query type',
  59.             'empty_data'  => null
  60.         ));
  61.         $builder->add('subject'null, array(
  62.             'required' => true,
  63.             'label' => 'Subject',
  64.             'mapped' => false,
  65.             'attr' => ['placeholder' => 'Enter Subject'],
  66.         ));
  67.         
  68.         $builder->add('reply'TextareaType::class, array(
  69.             'label' => 'Message',
  70.             'mapped' => false,
  71.             'attr' => array(
  72.                 'placeholder' => 'Brief Description about your query',
  73.                 'data-iconlibrary' => "fa",
  74.                 'data-height' => "250",
  75.             ),
  76.         ));
  77.         $builder->add('attachments'FileType::class, array(
  78.             'label' => '+ Attach File',
  79.             'mapped' => false,
  80.             'multiple' => true,
  81.             'attr' => array(
  82.                 'mainLabel' => false,
  83.                 'infoLabel' => 'right',
  84.                 'infoLabelText' => '+ Attach File',
  85.                 'decorateFile' => true,
  86.                 'decorateCss' => 'attach-file',
  87.                 'enableRemoveOption' => true
  88.             ),
  89.         ));
  90.     }
  91.     /**
  92.      * {@inheritdoc}
  93.      */
  94.     public function configureOptions(OptionsResolver $resolver)
  95.     {
  96.         $resolver->setDefaults(array(
  97.             'data_class' => CoreEntites\Ticket::class,
  98.             'allow_extra_fields' => true,
  99.             'csrf_protection' => false
  100.         ));
  101.         
  102.         $resolver->setRequired('container');
  103.         $resolver->setRequired('entity_manager');
  104.     }
  105.     /**
  106.      * {@inheritdoc}
  107.      */
  108.     public function getName()
  109.     {
  110.         return '';
  111.     }
  112. }