src/Form/GuardianRegister/GuardianRegisterChildType.php line 21

Open in your IDE?
  1. <?php
  2. namespace App\Form\GuardianRegister;
  3. use App\Entity\GuardianRegister\GuardianRegisterChild;
  4. use App\Entity\GuardianRegister\GuardianRegisterChildPreference;
  5. use App\Utils\HelperUtils;
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\Extension\Core\Type\ButtonType;
  8. use Symfony\Component\Form\Extension\Core\Type\CheckboxType;
  9. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  10. use Symfony\Component\Form\Extension\Core\Type\CollectionType;
  11. use Symfony\Component\Form\Extension\Core\Type\FormType;
  12. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  13. use Symfony\Component\Form\Extension\Core\Type\TextType;
  14. use Symfony\Component\Form\Extension\Core\Type\TextareaType;
  15. use Symfony\Component\Form\FormBuilderInterface;
  16. use Symfony\Component\OptionsResolver\OptionsResolver;
  17. use Symfony\Component\Routing\Generator\UrlGeneratorInterface;
  18. class GuardianRegisterChildType extends AbstractType
  19. {
  20. private UrlGeneratorInterface $urlGenerator;
  21. public function __construct(UrlGeneratorInterface $urlGenerator)
  22. {
  23. $this->urlGenerator = $urlGenerator;
  24. }
  25. public function buildForm(FormBuilderInterface $builder, array $options): void
  26. {
  27. $availabilityUrl = $this->urlGenerator->generate('teacher_availability_index');
  28. $availabilityQuantityUrl = $this->urlGenerator->generate('teacher_availability_quantity');
  29. $builder
  30. ->add('name', null, [
  31. 'label' => 'guardian_register.firstname',
  32. // 'data' => 'Vardas1'
  33. ])
  34. ->add('email', null, [
  35. 'label' => 'guardian_register.email',
  36. // 'data' => 'Vardas1'
  37. ])
  38. ->add('class', ChoiceType::class, [
  39. 'choices' => [
  40. "<1" => 0,
  41. 1 => 1,
  42. 2 => 2,
  43. 3 => 3,
  44. 4 => 4,
  45. 5 => 5,
  46. 6 => 6,
  47. 7 => 7,
  48. 8 => 8,
  49. 9 => 9,
  50. 10 => 10,
  51. 11 => 11,
  52. 12 => 12,
  53. ">12" => 13,
  54. ],
  55. 'multiple' => false,
  56. 'label' => 'forms.labels.class'
  57. ])
  58. ->add('admin_comment', null, [
  59. 'row_attr' => [
  60. 'class' => '',
  61. ],
  62. ])
  63. ->add('calendar', null, [
  64. 'label' => false,
  65. 'mapped' => false,
  66. 'row_attr' => [
  67. 'class' => 'calendar-block',
  68. ],
  69. ]
  70. );
  71. $subForm = $builder->create("fittingTimesWrap", FormType::class, [
  72. // 'by_reference' => false,
  73. // 'mapped' => false,
  74. 'label' => false,
  75. 'inherit_data' => true,
  76. 'row_attr' => ['class' => 'fittingTimesWrap'],
  77. ])
  78. ->add('fittingTimes', TextAreaType::class, [
  79. 'label' => 'forms.labels.fittingTimes',
  80. 'attr' => ['readonly' => true, 'rows' => 5,],
  81. 'row_attr' => [
  82. 'class' => 'text-block',
  83. ],
  84. 'required' => false,
  85. ])
  86. ->add('fittingTimesPriority', TextAreaType::class, [
  87. 'label' => 'Prioritetiniai užsiėmimų laikai',
  88. 'attr' => ['readonly' => true, 'rows' => 4,],
  89. 'row_attr' => [
  90. 'class' => 'text-block',
  91. ],
  92. 'required' => false,
  93. ])
  94. ->add('flagRU', CheckboxType::class, ['label' => 'RU', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  95. ->add('flagPL', CheckboxType::class, ['label' => 'PL', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  96. ->add('flagENG', CheckboxType::class, ['label' => 'ENG', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  97. ->add('flagIB', CheckboxType::class, ['label' => 'IB', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  98. ->add('flagIelts', CheckboxType::class, ['label' => 'IELTS', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  99. ->add('flagDyslexia', CheckboxType::class, ['label' => 'Disleksija', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  100. ->add('flagSensitive', CheckboxType::class, ['label' => 'Jautrus', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  101. ->add('flagStrict', CheckboxType::class, ['label' => 'Griežtumo reikia', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  102. ->add('vbeOver90', CheckboxType::class, ['label' => 'VBE nuo 90', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  103. ->add('experienceOver12Month', CheckboxType::class, ['label' => 'Patirtis nuo 12 mėn', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  104. ->add('flagExperienceAtSchool', CheckboxType::class, ['label' => 'Turi patirties dirbant mokykloje / turi pedagoginį išsilavinimą', 'required' => false, 'row_attr' => ['class' => 'fit-inline']])
  105. ->add('gender', ChoiceType::class, [
  106. 'choices' => [
  107. "Nesvarbu" => "Nesvarbu",
  108. "Mergina" => "Mergina",
  109. "Vaikinas" => "Vaikinas",
  110. ],
  111. 'label' => 'Mergina/Vaikinas',
  112. 'required' => false,
  113. ])
  114. ->add('school', ChoiceType::class, [
  115. 'label' => 'Mokykla, kurioje mokėsi tutor',
  116. 'choices' => HelperUtils::getSchools(),
  117. 'placeholder' => 'Prašome pasirinkti',
  118. 'required' => false,
  119. ]);
  120. // $builder->add('fittingTimes', null, [
  121. // 'label' => 'forms.labels.fittingTimes',
  122. // 'attr' => ['readonly' => true, 'rows' => 5,],
  123. // 'row_attr' => [
  124. // 'class' => 'text-block',
  125. // ],
  126. // ])
  127. // ->add('fittingTimesPriority', null, [
  128. // 'label' => 'Prioritetiniai užsiėmimų laikai',
  129. // 'attr' => ['readonly' => true, 'rows' => 5,],
  130. // 'row_attr' => [
  131. // 'class' => 'text-block',
  132. // ],
  133. // ]);
  134. $builder->add($subForm);
  135. $builder->add('guardianRegisterChildPreferences', CollectionType::class, [
  136. 'entry_type' => GuardianRegisterChildPreferenceType::class,
  137. 'allow_add' => true,
  138. 'allow_delete' => true,
  139. 'prototype' => true,
  140. 'prototype_data' => (new GuardianRegisterChildPreference())->setDuration(60)->setAmount(2),
  141. 'prototype_name' => '__guardianRegisterChildPreferencesName__',
  142. 'attr' => [
  143. 'inline-add' => true,
  144. 'btn-delete-label' => 'Naikinti nustatymą',
  145. 'btn-add-label' => 'Pridėti nustatymą',
  146. 'class' => 'add-new',
  147. 'data-widget-tags' => 'flex-add-new',
  148. 'data-widget-delete' => '<button class="btn btn-danger" type="button" onclick="this.parentNode.parentNode.remove()">Naikinti nustatymą</button>'
  149. ],
  150. 'row_attr' => [
  151. 'class' => 'collection-type-flex',
  152. ],
  153. 'label' => 'guardian_register.guardianRegisterChildPreferences'
  154. ])
  155. ->add('tutorBadge', FormType::class, [
  156. 'label' => 'Laisvi korepetitoriai <span class="pill-count">0</span>&nbsp;&nbsp;<button type="submit" class="pill-preview-action pill-preview-action-search" formmethod="post" formaction="' . $availabilityUrl . '" formtarget="_blank" formnovalidate><i class="ti-search"></i></button>&nbsp;&nbsp;<button type="button" class="pill-preview-action pill-preview-action-reload" data-url="' . $availabilityQuantityUrl . '"><i class="ti-reload"></i></button>',
  157. 'label_html' => true,
  158. 'mapped' => false,
  159. 'required' => false,
  160. 'row_attr' => [
  161. 'class' => 'pill-preview-row',
  162. ],
  163. 'label_attr' => [
  164. 'class' => 'pill-preview-label',
  165. ],
  166. ])
  167. ->add('tutorComment');
  168. }
  169. public function configureOptions(OptionsResolver $resolver): void
  170. {
  171. $resolver->setDefaults([
  172. 'data_class' => GuardianRegisterChild::class,
  173. ]);
  174. }
  175. }