Advertisement
Alfredao

Encargo Valor Fieldset

Mar 7th, 2014
142
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 2.25 KB | None | 0 0
  1. <?php
  2. namespace Cadastro\Form;
  3.  
  4. use Cadastro\Entity\EncargoValor;
  5. use Doctrine\Common\Persistence\ObjectManager;
  6. use DoctrineModule\Stdlib\Hydrator\DoctrineObject;
  7. use Zend\Form\Fieldset;
  8. use Zend\InputFilter\InputFilterProviderInterface;
  9. use Application\Filter\StrToFloat;
  10.  
  11. class EncargoValorFieldset extends Fieldset implements InputFilterProviderInterface
  12. {
  13.  
  14.     public function __construct(ObjectManager $objectManager)
  15.     {
  16.         parent::__construct('valor');
  17.        
  18.         $this->setHydrator(new DoctrineObject($objectManager))->setObject(new EncargoValor());
  19.        
  20.         $this->add(array(
  21.             'type' => 'Cadastro\Form\Element\Money',
  22.             'name' => 'valorInicial',
  23.             'options' => array(
  24.                 'label' => 'Valor inicial'
  25.             ),
  26.             'attributes' => array(
  27.                 'class' => 'form-control money'
  28.             )
  29.         ));
  30.        
  31.         $this->add(array(
  32.             'type' => 'Cadastro\Form\Element\Money',
  33.             'name' => 'valorFinal',
  34.             'options' => array(
  35.                 'label' => 'Valor final'
  36.             ),
  37.             'attributes' => array(
  38.                 'class' => 'form-control money'
  39.             )
  40.         ));
  41.        
  42.         $this->add(array(
  43.             'type' => 'Cadastro\Form\Element\Money',
  44.             'name' => 'valorEncargo',
  45.             'options' => array(
  46.                 'label' => 'Valor encargo'
  47.             ),
  48.             'attributes' => array(
  49.                 'class' => 'form-control money'
  50.             )
  51.         ));
  52.    
  53.     }
  54.  
  55.     /**
  56.      * (non-PHPdoc)
  57.      *
  58.      * @see \Application\Model\Model::getInputFilter()
  59.      */
  60.     public function getInputFilterSpecification()
  61.     {
  62.         return [
  63.             'id' => [
  64.                 'required' => false
  65.             ],
  66.             'valorInicial' => [
  67.                 'filters' => [
  68.                     new StrToFloat()
  69.                 ]
  70.             ],
  71.             'valorFinal' => [
  72.                 'filters' => [
  73.                     new StrToFloat()
  74.                 ]
  75.             ],
  76.             'valorEncargo' => [
  77.                 'filters' => [
  78.                     new StrToFloat()
  79.                 ]
  80.             ]
  81.         ];
  82.     }
  83.    
  84. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement