Posted By

uthopiko on 07/22/12


Tagged

form


Versions (?)

Formulario


 / Published in: PHP
 

Problema Form

  1. <?php
  2. namespace Eros\ExtranetBundle\Form\Ty;
  3.  
  4. use Symfony\Component\Form\AbstractType;
  5. use Symfony\Component\Form\FormBuilder;
  6.  
  7. class PromocionType extends AbstractType
  8. {
  9. private $id;
  10.  
  11. public function __construct($class,$id)
  12. {
  13. $this->class = $class;
  14. $this->id = $id;
  15. }
  16.  
  17. public function buildForm(FormBuilder $builder, array $options)
  18. {
  19. //$id = $options['attr']['id'];
  20. $builder->add('Nombre', 'text',array('attr'=> array('class'=>'first')));
  21. $builder->add('Descripcion', 'text',array('attr'=> array('class'=>'first')));
  22. $builder->add('Descuento', 'text',array('attr'=> array('class'=>'first')));
  23. $builder->add('FechaInicio', 'text',array('required'=>false,'attr'=> array('class'=>'calendar second')));
  24. $builder->add('FechaFin', 'text',array('required'=>false,'attr'=> array('class'=>'calendar second')));
  25. $builder->add('TipoPromocion', 'choice', array('choices' => array(
  26. '1' => 'General',
  27. '2' => 'Articulos')));
  28. $builder->add('TipoDescuento', 'entity', array('class' => 'ErosBackendBundle:MstTipoDescuento','attr' => array('class'=>'second','style' => 'display:none'),'property' => 'Descuento'));
  29. $builder->add('TipoDescuento2', 'entity', array('class' => 'ErosBackendBundle:MstTipoDescuento','property' => 'Descuento','property_path' => false));
  30. $builder->add('ddlArticulo','entity',
  31. array('class' => 'ErosFrontendBundle:ProArticulo','property_path' => false,
  32. 'query_builder' => function ($repository) use ($id) {
  33. $qb = $repository->createQueryBuilder('ErosFrontendBundle:ProArticulo');
  34. $qb->add('where', 'ErosFrontendBundle:ProArticulo.empresa = :empresa');
  35. $qb->setParameter('empresa',$id);
  36. return $qb;
  37. },'required' => true,'property' => 'Nombre'));
  38.  
  39. }
  40.  
  41. public function getName()
  42. {
  43. return 'PromocionType';
  44. }
  45. }

Report this snippet  

You need to login to post a comment.