src/Form/Scholar/PracticalCaseResponseType.php line 14

Open in your IDE?
  1. <?php
  2. namespace App\Form\Scholar;
  3. use App\Entity\Scholar\PracticalCase\FilePracticalCaseResponse;
  4. use App\Entity\Scholar\PracticalCase\PracticalCaseResponse;
  5. use App\Form\Common\CustomFileType;
  6. use Nellapp\Bundle\SDKBundle\Form\Common\NellappDurationType;
  7. use Symfony\Component\Form\AbstractType;
  8. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  9. use Symfony\Component\Form\FormBuilderInterface;
  10. use Symfony\Component\OptionsResolver\OptionsResolver;
  11. class PracticalCaseResponseType extends AbstractType
  12. {
  13.     public function buildForm(FormBuilderInterface $builder, array $options): void
  14.     {
  15.         $enableCustomTime $options['enableCustomTime'];
  16.         $builder
  17.             ->add('content'TextareaType::class, [
  18.                 'label' => 'practical_case_response.content.label',
  19.                 'label_attr' => [
  20.                     'class' => 'label-custom-practical small-margin-bottom'
  21.                 ],
  22.                 'required' => true,
  23.                 'attr' => [
  24.                     'data-tinymce' => true,
  25.                     'data-tinymce-height' => 150,
  26.                     'data-lite' => true,
  27.                     'placeholder' => 'practical_case_response.content.placeholder',
  28.                 ]
  29.             ])
  30.             ->add('file'CustomFileType::class, [
  31.                 'data_class' => FilePracticalCaseResponse::class,
  32.                 'label' => false,
  33.                 'row_attr' => [
  34.                     'class' => 'd-none'
  35.                 ],
  36.                 'upload_endpoint' => 'practical_case_response_file',
  37.                 'required' => false,
  38.                 'mapped' => true,
  39.                 'extensions' => [
  40.                     'pdf',
  41.                     'jpg',
  42.                     'jpeg',
  43.                     'png',
  44.                     'mp4',
  45.                     'zip',
  46.                     'ppt',
  47.                     'xls',
  48.                     'doc'
  49.                 ],
  50.             ]);
  51.         if ($enableCustomTime) {
  52.             $builder
  53.                 ->add('customTime'NellappDurationType::class, [
  54.                     'label' => 'practical_case_response.custom_time.label',
  55.                     'required' => false,
  56.                     'property_path' => 'practicalCaseUser.customTime',
  57.                 ]);
  58.         }
  59.     }
  60.     public function configureOptions(OptionsResolver $resolver): void
  61.     {
  62.         $resolver->setDefaults([
  63.             'data_class' => PracticalCaseResponse::class,
  64.             'attr' => [
  65.                 'id' => 'practical-case-response-form',
  66.             ],
  67.             'enableCustomTime' => false,
  68.         ]);
  69.         $resolver->setAllowedTypes('enableCustomTime', ['bool']);
  70.     }
  71. }