icefusion

Zend Form

Dec 12th, 2012
207
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 3.25 KB | None | 0 0
  1. <?php
  2.  
  3. class Icefusion_View_Helper_Admin_Forms_SkuOptions extends Zend_Form{
  4.  
  5.     public function getFormCadastro($data) {
  6.         $form = new Zend_Form;
  7.  
  8.         $form->setMethod('post');
  9.         $form->setAction('/admin/skuoptions/save');    
  10.         $form->setAttrib('enctype', 'multipart/form-data');
  11.         $form->setAttrib('id', 'form-application');
  12.        
  13.         $sku = new Zend_Form_Element_Select('sku_id', array('label' => 'Sku:', 'class' => 'select2 borda-arredondada'));
  14.         $sku->addDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row2'))));
  15.         $skuList = new Application_Model_Sku();
  16.  
  17.         $result = $skuList->fetchAll('id > 0','name')->toArray();
  18.         $options = array();
  19.         foreach ($result as $value) {
  20.             $options[$value['id']] = $value['name'];
  21.         }
  22.  
  23.         $sku->setMultiOptions($options);
  24.         $sku->setRequired(true);
  25.         $form->addElement($sku);
  26.        
  27.         $nome = $form->createElement('text', 'name', array('label' => 'Nome:', 'class' => 'campos4 borda-arredondada'))->setRequired(true);
  28.         $nome->addDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row4'))));
  29.         $form->addElement($nome);
  30.        
  31.         $color = $form->createElement('text', 'color', array('label' => 'Cor:', 'class' => 'campos1 borda-arredondada'))->setRequired(true);
  32.         $color->addDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row1'))));
  33.         $form->addElement($color);        
  34.        
  35.         $arquivojpg = new Zend_Form_Element_File('arquivojpg');
  36.         $arquivojpg->setLabel('Enviar Perspectiva JPG:');        
  37.         $arquivojpg->addValidator('Count', false, 1);                
  38.         $arquivojpg->addValidator('Extension', false, 'jpg');
  39.         $arquivojpg->addDecorators(array('File', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row3'))));
  40.         $form->addElement($arquivojpg);
  41.        
  42.         $arquivoswf = new Zend_Form_Element_File('arquivoswf');
  43.         $arquivoswf->setLabel('Enviar Perspectiva SWF:');        
  44.         $arquivoswf->addValidator('Count', false, 1);        
  45.         //$arquivoswf->addValidator('Extension', false, 'swf');
  46.         $arquivoswf->addDecorators(array('File', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row3'))));
  47.         $form->addElement($arquivoswf);
  48.  
  49.         $id = $form->createElement('hidden', 'id');
  50.         $form->addElement($id);
  51.  
  52.         $submit = $form->createElement('submit', 'submit', array('label' => 'Salvar', 'class' => 'btn btn-salvar'));
  53.         $submit->addDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row2'))));
  54.         $form->addElement($submit);
  55.  
  56.         $limpar = $form->createElement('button', 'button', array('label' => 'Limpar', 'class' => 'btn btn-limpar'));
  57.         $limpar->addDecorators(array('ViewHelper', array(array('row' => 'HtmlTag'), array('tag' => 'div', 'class' => 'row2'))));
  58.         $form->addElement($limpar);
  59.  
  60.         if ($data) {
  61.             $form->populate($data);
  62.         }
  63.  
  64.         return $form;
  65.  
  66.         //$form->addElement('hash', 'csrf');
  67.     }  
  68. }
Advertisement
Add Comment
Please, Sign In to add comment