Advertisement
xeonist

PlumeOptionsType.php

Oct 19th, 2011
343
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 1.60 KB | None | 0 0
  1. <?php
  2. // src/Dessin/PlumeBundle/Form/Type/PlumeOptionsType.php
  3.  
  4. namespace Dessin\PlumeBundle\Form\Type;
  5.  
  6. use Symfony\Component\Form\AbstractType;
  7. use Symfony\Component\Form\FormBuilder;
  8. use Doctrine\ORM\EntityRepository;
  9. use Dessin\ProfileBundle\Entity\Profile;
  10.  
  11. class PlumeOptionsType extends AbstractType
  12. {
  13.     protected $profile;
  14.    
  15.     public function __construct ($profile1)
  16.     {
  17.         $this->profile = $profile1;
  18.     }
  19.    
  20.     public function buildForm(FormBuilder $builder, array $options)
  21.     {
  22.        
  23.         //$builder->add('framePlume');
  24.         $builder->add('cartridgePlume');
  25.         $builder->add('noticePlume');
  26.         $builder->add('activePalette');
  27.         //echo  "data" . $this->profile;
  28.         $builder->add('framePlume', 'entity', array(
  29.             'class' => 'DessinPlumeBundle:PhysicalPlume',
  30.             'query_builder' => function(EntityRepository $er) {                                    
  31.                                       return $er->createQueryBuilder('pp')
  32.                                         ->where("pp.profile = :profile")
  33.                                         ->orderBy('pp.index', 'ASC')
  34.                                         //->setParameter('profile', $this->profile)
  35.                                         ->setParameter('profile', 1)
  36.                                        
  37.                                     ;
  38.                                 },
  39.                                
  40.         ));
  41.     }
  42.  
  43.     public function getName()
  44.     {
  45.         #should return a unique identifier for this form "type"
  46.         return 'plumeOptions';
  47.     }
  48.    
  49.     public function getDefaultOptions(array $options)
  50.     {
  51.         return array(
  52.                 'data_class'      => 'Dessin\PlumeBundle\Entity\PlumeOptions',
  53.                 'csrf_protection' => true,
  54.                 'csrf_field_name' => '_token',
  55.                 // a unique key to help generate the secret token
  56.                 'intention'       => 'plumeOptions_item',
  57.         );
  58.     }
  59. }
  60.  
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement