Share Pastebin
Guest
Public paste!

mon

By: a guest | Mar 5th, 2009 | Syntax: PHP | Size: 6.29 KB | Hits: 41 | Expires: Never
Copy text to clipboard
  1. class DecorsController extends Zend_Controller_Action
  2. {
  3.     public function indexAction()
  4.     {
  5.         $this->getHelper('ViewRenderer')->setNoRender(true);
  6.  
  7.         $elementLi = array(
  8.             'ViewHelper',
  9.             'Label',
  10.             'Errors',
  11.             array('HtmlTag', array('tag' => 'li'))
  12.         );
  13.         $checkboxLi = array(
  14.             'ViewHelper',
  15.             array('Label', array('placement' => 'append')),
  16.             array(array('elemWrap' => 'HtmlTag'), array('tag' => 'div', 'class' => 'checkbox-wrap')),
  17.             array('Description', array('tag' => 'label', 'placement' => 'prepend')),
  18.             'Errors',
  19.             array(array('wrap' => 'HtmlTag'), array('tag' => 'li'))
  20.         );
  21.         $buttonLi = array(
  22.             'ViewHelper',
  23.             array('HtmlTag', array('tag' => 'li', 'class' => 'button'))
  24.         );
  25.         $formUl = array(
  26.             'FormElements',
  27.             array('HtmlTag', array('tag' => 'ul', 'class' => 'list-form')),
  28.             'Form'
  29.         );
  30.  
  31.         $elementTr = array(
  32.             'Label',
  33.             array(array('labelTd' => 'HtmlTag'), array('tag' => 'td', 'class' => 'labelWrap')),
  34.             array(array('elemTdOpen' => 'HtmlTag'), array('tag' => 'td', 'openOnly' => true, 'placement' => 'append')),
  35.             'ViewHelper',
  36.             'Errors',
  37.             array(array('elemTdClose' => 'HtmlTag'), array('tag' => 'td', 'closeOnly' => true, 'placement' => 'append')),
  38.             array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
  39.         );
  40.         $checkboxTr = array(
  41.             array('Description', array('tag' => 'label')),
  42.             array(array('labelTd' => 'HtmlTag'), array('tag' => 'td', 'class' => 'labelWrap')),
  43.             array(array('elemTdOpen' => 'HtmlTag'), array('tag' => 'td', 'openOnly' => true, 'placement' => 'append')),
  44.             'ViewHelper',
  45.             array('Label', array('placement' => 'append')),
  46.             'Errors',
  47.             array(array('elemTdClose' => 'HtmlTag'), array('tag' => 'td', 'closeOnly' => true, 'placement' => 'append')),
  48.             array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
  49.         );
  50.         $buttonTr = array(
  51.             'Description',
  52.             array(array('labelTd' => 'HtmlTag'), array('tag' => 'td', 'class' => 'labelWrap')),
  53.             array(array('elemTdOpen' => 'HtmlTag'), array('tag' => 'td', 'openOnly' => true, 'placement' => 'append')),
  54.             'ViewHelper',
  55.             array(array('elemTdClose' => 'HtmlTag'), array('tag' => 'td', 'closeOnly' => true, 'placement' => 'append')),
  56.             array(array('row' => 'HtmlTag'), array('tag' => 'tr'))
  57.         );
  58.         $formTable = array(
  59.             'FormElements',
  60.             array('HtmlTag', array('tag' => 'table', 'class' => 'table-form')),
  61.             'Form'
  62.         );
  63.  
  64.         $elementDl = array(
  65.             array('Label', array('tag' => 'dt')),
  66.             array(array('ddOpen' => 'HtmlTag'), array('tag' => 'dd', 'openOnly' => true, 'placement' => 'append')),
  67.             'ViewHelper',
  68.             'Errors',
  69.             array(array('ddClose' => 'HtmlTag'), array('tag' => 'dd', 'closeOnly' => true, 'placement' => 'append')),
  70.             array(array('dl' => 'HtmlTag'), array('tag' => 'dl'))
  71.         );
  72.         $checkboxDl = array(
  73.             array('Description', array('tag' => 'label')),
  74.             array(array('dt' => 'HtmlTag'), array('tag' => 'dt')),
  75.             array(array('ddOpen' => 'HtmlTag'), array('tag' => 'dd', 'openOnly' => true, 'placement' => 'append')),
  76.             'ViewHelper',
  77.             array('Label', array('placement' => 'append')),
  78.             'Errors',
  79.             array(array('ddClose' => 'HtmlTag'), array('tag' => 'dd', 'closeOnly' => true, 'placement' => 'append')),
  80.             array(array('dl' => 'HtmlTag'), array('tag' => 'dl'))
  81.         );
  82.         $buttonDl = array(
  83.             array(array('dt' => 'HtmlTag'), array('tag' => 'dt')),
  84.             array(array('ddOpen' => 'HtmlTag'), array('tag' => 'dd', 'openOnly' => true, 'placement' => 'append')),
  85.             'ViewHelper',
  86.             array(array('ddClose' => 'HtmlTag'), array('tag' => 'dd', 'closeOnly' => true, 'placement' => 'append')),
  87.             array(array('dl' => 'HtmlTag'), array('tag' => 'dl'))
  88.         );
  89.         $formDl = array(
  90.             'FormElements',
  91.             array('HtmlTag', array('tag' => 'div', 'class' => 'dl-form')),
  92.             'Form'
  93.         );
  94.  
  95.         $text = new Zend_Form_Element_Text('foo', array('label' => 'Foo:'));
  96.         $select = new Zend_Form_Element_Select('bar', array('label' => 'Bar:'));
  97.         $select->setMultiOptions(array('one', 'two', 'three'));
  98.         $textarea = new Zend_Form_Element_Textarea('baz', array('label' => 'Baz:'));
  99.         $checkbox = new Zend_Form_Element_Checkbox('bat', array('description' => 'What?', 'label' => 'Yes'));
  100.         $radio = new Zend_Form_Element_Radio('quux', array('description' => 'Choose one:'));
  101.         $radio->setMultiOptions(array('first', 'second', 'third'));
  102.         $submit = new Zend_Form_Element_Submit('submit', array('label' => 'Submit'));
  103.  
  104.         $elements = array($text, $select, $textarea, $checkbox, $radio, $submit);
  105.         foreach ($elements as $elem) {
  106.             $elem->addError('some error');
  107.         }
  108.  
  109.         $form = new Zend_Form();
  110.         $form->addElements($elements);
  111.  
  112.         $text->setDecorators($elementLi);
  113.         $select->setDecorators($elementLi);
  114.         $textarea->setDecorators($elementLi);
  115.         $checkbox->setDecorators($checkboxLi);
  116.         $radio->setDecorators($checkboxLi);
  117.         $submit->setDecorators($buttonLi);
  118.         $form->setDecorators($formUl);
  119.         echo $form;
  120.  
  121.         $text->setDecorators($elementTr);
  122.         $select->setDecorators($elementTr);
  123.         $textarea->setDecorators($elementTr);
  124.         $checkbox->setDecorators($checkboxTr);
  125.         $radio->setDecorators($checkboxTr);
  126.         $submit->setDecorators($buttonTr);
  127.         $form->setDecorators($formTable);
  128.         echo $form;
  129.  
  130.         $text->setDecorators($elementDl);
  131.         $select->setDecorators($elementDl);
  132.         $textarea->setDecorators($elementDl);
  133.         $checkbox->setDecorators($checkboxDl);
  134.         $radio->setDecorators($checkboxDl);
  135.         $submit->setDecorators($buttonDl);
  136.         $form->setDecorators($formDl);
  137.         echo $form;
  138.     }
  139. }