src/Form/AlertaType.php line 17

  1. <?php
  2. namespace App\Form;
  3. use Symfony\Component\Form\AbstractType;
  4. use Symfony\Component\Form\FormBuilderInterface;
  5. use Symfony\Component\OptionsResolver\OptionsResolver;
  6. use Symfony\Component\Validator\Constraints\NotBlank;
  7. use Symfony\Component\Validator\Constraints\NotNull;
  8. use Symfony\Component\Validator\Constraints\Email;
  9. use App\Entity\Alerta;
  10. use Symfony\Component\Form\Extension\Core\Type\DateType;
  11. use Symfony\Component\Form\Extension\Core\Type\TextType;
  12. use Symfony\Component\Form\Extension\Core\Type\ChoiceType;
  13. use Symfony\Component\Form\Extension\Core\Type\NumberType;
  14. class AlertaType extends AbstractType
  15. {
  16.     public function buildForm(FormBuilderInterface $builder, array $options)
  17.     {
  18.         $builder
  19.             ->add('fechaInicio'DateType::class, array(
  20.                                             'html5'     => true,
  21.                                             'attr' =>[
  22.                                                 'class' => 'datepicker fechas1'
  23.                                             ],
  24.                                             'label' => false,
  25.                                             'required' => true,
  26.                                             'widget' => 'single_text',
  27.                                             'constraints' => array(new NotBlank()),
  28.                                             )
  29.             )
  30.             ->add('fechaFin'DateType::class, array(
  31.                                             'html5'     => true,
  32.                                             'attr' =>[
  33.                                                 'class' => 'datepicker fechas1'
  34.                                             ],
  35.                                             'label' => false,
  36.                                             'data'  => null,
  37.                                             'required' => false,
  38.                                             'widget' => 'single_text',
  39.                         )
  40.             )
  41.             ->add('divisa'null, array(
  42.                                             'attr' =>[
  43.                                                 'class' => 'hidden'
  44.                                             ],
  45. //                                             'property' => 'nombre',
  46.                                             'label' => false,
  47.                                             'required' => true,
  48.                                             'constraints' => array(
  49.                                                                 new NotBlank(),
  50.                                                             ),
  51.                                             )
  52.             )
  53.             ->add('oficina'null, array(
  54.                                             'attr' =>[
  55.                                                 'class' => 'hidden'
  56.                                             ],
  57.                                             'label' => false,
  58.                                             'required' => true,
  59.                                             'constraints' => array(
  60.                                                                 new NotBlank(),
  61.                                                             ),
  62.                                             )
  63.             )
  64.             ->add('precioMinimo'NumberType::class, array(
  65.                         'label'     => false,
  66.                         'required'  => false
  67.             ))
  68.             ->add('frecuencia'ChoiceType::class, array(
  69.                                             'attr' =>[
  70.                                             ],
  71.                                             'choices'  => array_flip([
  72.                                                 => $options['settings']->getValue('currency.alert.daily'),
  73.                                                 => $options['settings']->getValue('currency.alert.weekly'),
  74.                                                 30 => $options['settings']->getValue('currency.alert.monthly'),
  75.                                             ]),
  76.                                             'data' => 1,
  77.                                             'expanded' => true,
  78.                                             'multiple' => false,
  79.                                             'required' => true,
  80.                                             'constraints' => array(
  81.                                                                 new NotBlank(),
  82.                                                             ),
  83.                                             )
  84.             )
  85.             ->add('tipo'ChoiceType::class, [
  86.                 'attr' =>[
  87.                         'class' => 'hidden'
  88.                     ],
  89.                 'label' => false,
  90.                 'choices' => [
  91.                     'Venta' => 1,
  92.                     'Compra' => 0,
  93.                 ],
  94.                 'data' => 1,
  95.                 'expanded' => true,
  96.                 'multiple' => false,
  97.                 'required' => true,
  98.             ]);
  99.         ;
  100.     }
  101.     
  102.     
  103.     public function configureOptions(OptionsResolver $resolver)
  104.     {
  105.         
  106.         $resolver
  107.             ->setRequired( array('settings') )
  108.         ;
  109.     }
  110.     public function getName()
  111.     {
  112.         return 'dinamic_alerta';
  113.     }
  114. }