Advertisement
Guest User

QuoteForm

a guest
Jul 24th, 2013
173
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.03 KB | None | 0 0
  1. <?php
  2.  
  3. namespace Application\Form;
  4.  
  5. use \Application\Form\AbstractForm;
  6.  
  7. class Quote extends AbstractForm
  8. {
  9.  
  10.     public function __construct($em = null)
  11.     {
  12.         parent::__construct($em);
  13.              
  14.         $this->add(array(
  15.             'name'    => 'name',
  16.             'type'    => 'text',
  17.             'options' => array(
  18.                 'label' => 'Nom'
  19.             ),
  20.             'attributes' => array(
  21.                 'required' => true,
  22.                 'class' => 'input-block-level',
  23.             ),
  24.         ));
  25.        
  26.         $this->add(array(
  27.             'name'    => 'email',
  28.             'type'    => 'email',
  29.             'options' => array(
  30.                 'label' => 'Courriel'
  31.             ),
  32.             'attributes' => array(
  33.                 'required' => true,
  34.                 'class' => 'input-block-level',
  35.             ),
  36.         ));
  37.        
  38.         $this->add(array(
  39.             'name'    => 'phone_number',
  40.             'type'    => 'text',
  41.             'options' => array(
  42.                 'label' => 'Téléphone'
  43.             ),
  44.             'attributes' => array(
  45.                 'class' => 'input-block-level',
  46.                 'required' => true,
  47.             ),
  48.         ));
  49.        
  50.         $budget = array(
  51.             500.00 => '500.00 $'
  52.         );
  53.        
  54.         for ($i = 1; $i <= 10; $i++) {
  55.             $val = number_format($i * 1000, 2, '.', '');
  56.            
  57.             $budget[$val] = $val . ' $';
  58.         }
  59.        
  60.         $this->add(array(
  61.             'name'    => 'budget',
  62.             'type'    => 'select',
  63.             'options' => array(
  64.                 'label' => 'Budget',
  65.                 'value_options' => $budget,
  66.             ),
  67.             'attributes' => array(
  68.                 'class' => 'input-block-level',
  69.                 'required' => true,
  70.             ),
  71.         ));
  72.        
  73.         $this->add(array(
  74.             'name' => 'service',
  75.             'type' => 'DoctrineModule\Form\Element\ObjectSelect',
  76.             'options' => array(
  77.                 'label' => 'Service',
  78.                
  79.                 'object_manager' => $this->getObjectManager(),
  80.                 'target_class'   => 'Application\Entity\Service',
  81.                 'property'       => 'name',
  82.                 'label_generator' => function($targetEntity) {
  83.                     $targetEntity->getName();
  84.                 },
  85.             ),
  86.             'attributes' => array(
  87.                 'required' => true,
  88.                 'class' => 'input-block-level',
  89.             ),
  90.         ));
  91.        
  92.         $this->add(array(
  93.             'name' => 'content',
  94.             'type'  => 'textarea',
  95.             'options' => array(
  96.                 'label' => 'Message'
  97.             ),
  98.             'attributes' => array(
  99.                 'class' => 'input-block-level',
  100.                 'required' => true,
  101.                 'rows' => 12,
  102.             ),
  103.         ));
  104.        
  105.         $this->add(array(
  106.             'name' => 'submit',
  107.             'type' => 'submit',
  108.             'attributes' => array(
  109.                 'value' => 'Envoyer',
  110.                 'class' => 'btn btn-primary',
  111.             ),
  112.         ));
  113.     }
  114.  
  115. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement