Alfredao

FormFeriado.php

Feb 7th, 2014
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.81 KB | None | 0 0
  1. <?php
  2. namespace Cadastro\Form;
  3.  
  4. use Zend\Form\Form;
  5. use DoctrineModule\Stdlib\Hydrator\DoctrineObject;
  6. use Zend\InputFilter\InputFilterProviderInterface;
  7. use Zend\Form\Element\Submit;
  8. use Cadastro\Hydrator\Strategy\DateTimeStrategy;
  9.  
  10. /**
  11.  * Cadastro de feriados e recesso.
  12.  *
  13.  * @author Alfredo Costa
  14.  * @category Form
  15.  * @package Cadastro/Form
  16.  * @copyright 2014 P21 Sistemas
  17.  * @version 1.0.0
  18.  */
  19. class FeriadoForm extends Form implements InputFilterProviderInterface
  20. {
  21.  
  22.     /**
  23.      */
  24.     public function __construct($objectManager)
  25.     {
  26.         parent::__construct('feriado');
  27.        
  28.         $this->setHydrator(new DoctrineObject($objectManager))->setObject(new \Cadastro\Entity\Feriado());
  29.        
  30.         /**
  31.          * Strategy para conversao de string [dataInicial|dataFinal] para object DateTime
  32.          */
  33.         $this->getHydrator()->addStrategy('dataInicial', new DateTimeStrategy());
  34.         $this->getHydrator()->addStrategy('dataFinal', new DateTimeStrategy());
  35.        
  36.         $this->add(array(
  37.             'type' => 'Zend\Form\Element\Hidden',
  38.             'name' => 'id'
  39.         ));
  40.        
  41.         $this->add(array(
  42.             'type' => 'Zend\Form\Element\Text',
  43.             'name' => 'nome',
  44.             'options' => array(
  45.                 'label' => 'Nome:'
  46.             ),
  47.             'attributes' => array(
  48.                 'size' => '30'
  49.             )
  50.         ));
  51.        
  52.         $this->add(array(
  53.             'type' => 'Zend\Form\Element\DateTime',
  54.             'name' => 'dataInicial',
  55.             'options' => array(
  56.                 'label' => 'Data inicial:',
  57.                 'format' => 'd/m/Y'
  58.             ),
  59.             'attributes' => array(
  60.                 'class' => 'data'
  61.             )
  62.         ));
  63.        
  64.         $this->add(array(
  65.             'type' => 'Zend\Form\Element\DateTime',
  66.             'name' => 'dataFinal',
  67.             'options' => array(
  68.                 'label' => 'Data final:',
  69.                 'format' => 'd/m/Y'
  70.             ),
  71.             'attributes' => array(
  72.                 'class' => 'data',
  73.                 'id' => 'dataFinal'
  74.             )
  75.         ));
  76.        
  77.         $this->add(array(
  78.             'type' => 'Zend\Form\Element\Checkbox',
  79.             'name' => 'extendido',
  80.             'options' => array(
  81.                 'label' => 'Extendido'
  82.             ),
  83.             'attributes' => array(
  84.                 'id' => 'extendido'
  85.             )
  86.         ));
  87.        
  88.         $this->add(array(
  89.             'type' => 'Zend\Form\Element\Submit',
  90.             'name' => 'submit',
  91.             'attributes' => array(
  92.                 'class' => 'submit',
  93.                 'value' => 'Confirmar'
  94.             )
  95.         ));
  96.     }
  97.  
  98.     public function getInputFilterSpecification()
  99.     {
  100.         return array();
  101.     }
  102. }
Advertisement
Add Comment
Please, Sign In to add comment