src/Form/VPN/Service/Service/UnlimitedV2rayType.php line 13

Open in your IDE?
  1. <?php
  2. namespace App\Form\VPN\Service\Service;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  5. use Symfony\Component\Form\Extension\Core\Type\HiddenType;
  6. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  7. use Symfony\Component\Form\Extension\Core\Type\TextType;
  8. use Symfony\Component\Form\FormBuilderInterface;
  9. use Symfony\Component\OptionsResolver\OptionsResolver;
  10. class UnlimitedV2rayType extends AbstractType
  11. {
  12.     public function buildForm(FormBuilderInterface $builder, array $options): void
  13.     {
  14.         $builder
  15.             ->add('serviceType'HiddenType::class, [
  16.                 'data' => 'unlimited'
  17.             ])
  18.             ->add('protocol'HiddenType::class, [
  19.                 'data' => 'v2ray'
  20.             ])
  21.             ->add('username' null , [
  22.                 'label' => 'نام انتخابی سرویس'
  23.             ])
  24.             ->add('password' null , [
  25.                 'label'=>'کلمه عبور انتخابی'
  26.             ])
  27.             ->add('clientId'NumberType::class, [
  28.                 'data' => $options['clientId'],
  29.                 'disabled' => true,
  30.                 'label' => 'شناسه یکتا سرویس'
  31.             ])
  32.             ->add('users'ChoiceType::class, [
  33.                 'attr' => ['class' => 'ajax-v2rayUnLimited'],
  34.                 'label' => 'تعداد کاربر مورد نیاز',
  35.                 'choices' => [
  36.                     'یک کاربر' => 1,
  37.                     'دو کاربر' => 2,
  38.                     'سه کاربر' => 3,
  39.                     'چهار کاربر' => 4,
  40.                     'پنج کاربر' => 5,
  41. //                    'بدون محدودیت کاربر' => 0,
  42.                 ]
  43.             ])
  44.             ->add('size'HiddenType::class, [
  45.                 'data' => 0
  46.             ])
  47.             ->add('country' ChoiceType::class, [
  48.                 'attr' => ['class' => 'ajax-v2rayUnLimited'],
  49.                 'label' => 'کشور',
  50.                 'choices' => $options['locations'] ,
  51. //                'choices' => [
  52. //                    'تمام کشور های موجود' => 'all'
  53. //                ] ,
  54.                 'mapped' => false,
  55.                 'required'=> true
  56.             ])
  57.             ->add('days'ChoiceType::class, [
  58.                 'attr' => ['class' => 'ajax-v2rayUnLimited'],
  59.                 'label' => 'زمان مورد نیاز',
  60.                 'choices' => [
  61.                     'یک ماه' => 30,
  62. //                    'دو ماه' => 60,
  63. //                    'سه ماه' => 90,
  64. //                    'شش ماه' => 180,
  65. //                    'دوازده ماه' => 365,
  66.                 ]
  67.             ]) ->add('price' TextType::class , [
  68.                 'label' => 'هزینه بسته انتخابی',
  69.                 'disabled' => true ,
  70.                 'mapped' => false,
  71.                 'data' => 'ابتدا موارد بالا را انتخاب فرمایید',
  72.                 'attr' => ['class' => 'form-control text-warning border-warning']
  73.             ]);
  74.     }
  75.     public function configureOptions(OptionsResolver $resolver): void
  76.     {
  77.         $resolver->setDefaults([
  78.             'clientId' => null,
  79.             'locations' => []
  80.         ]);
  81.     }
  82. }