src/Form/VPN/Service/Service/UnlimitedOpenType.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 UnlimitedOpenType 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' => 'open'
  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-openUnLimited'],
  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.                 'label' => 'کشور',
  49.                 'choices' => $options['locations'] ,
  50.                 'mapped' => false,
  51.                 'required'=> true
  52.             ])
  53.             ->add('days'ChoiceType::class, [
  54.                 'attr' => ['class' => 'ajax-openUnLimited'],
  55.                 'label' => 'زمان مورد نیاز',
  56.                 'choices' => [
  57.                     'یک ماه' => 30,
  58.                     'دو ماه' => 60,
  59.                     'سه ماه' => 90,
  60.                     'شش ماه' => 180,
  61.                     'دوازده ماه' => 365,
  62.                 ]
  63.             ])
  64.             ->add('price' TextType::class , [
  65.                 'label' => 'هزینه بسته انتخابی',
  66.                 'disabled' => true ,
  67.                 'mapped' => false,
  68.                 'data' => 'ابتدا موارد بالا را انتخاب فرمایید',
  69.                 'attr' => ['class' => 'form-control text-warning border-warning']
  70.             ]);
  71.     }
  72.     public function configureOptions(OptionsResolver $resolver): void
  73.     {
  74.         $resolver->setDefaults([
  75.             'clientId' => null,
  76.             'locations' => []
  77.         ]);
  78.     }
  79. }