Exemple #1
0
 /**
  * Change the current decorators
  *
  * @param \Zend_Form_Element $element
  * @param array $decorators
  */
 private function _applyDecorators(\Zend_Form_Element $element, array $decorators)
 {
     $element->clearDecorators();
     foreach ($decorators as $decorator) {
         call_user_func_array(array($element, 'addDecorator'), $decorator);
     }
 }
 /**
  * Will set up a task-element and decorators
  * @param string $id
  * @param array $values
  * @param array $attribs
  * @return Zend_Form_Element
  */
 protected function createTaskElement($id, $values, $isNew = false)
 {
     $elm = new Zend_Form_Element((string) $id);
     $elm->clearDecorators();
     $elm->addDecorator(new My_Decorator_TaskElement());
     $elm->addDecorator('Errors', array('placement' => 'prepend'));
     // add configured validator
     $validator = new My_Validator_TaskElement();
     $validator->setIsNew($isNew);
     $elm->addValidator($validator);
     return $elm;
 }
Exemple #3
0
 /**
  * Static function that adds all the elements in 1 wrapping element instead of dt, dd structure
  *
  * @param $elm
  * @return void
  */
 public static function setElementDecorator(Zend_Form_Element $elm)
 {
     $elm->addPrefixPath('Glitch_Form_Decorator', 'Glitch/Form/Decorator/', 'decorator');
     $labelSettings = array();
     if ($elm->getDecorator('Label')) {
         $labelSettings = $elm->getDecorator('Label')->getOptions();
         unset($labelSettings['tag']);
         //Tag should never be needed when you call this method
     }
     $class = 'wrapper';
     if ($elm->getAttrib('wrapperClass')) {
         $class .= ' ' . $elm->getAttrib('wrapperClass');
         $elm->setAttrib('wrapperClass', null);
     }
     if ($elm instanceof Zend_Form_Element_Hidden) {
         $class .= ' hidden';
     }
     $elm->clearDecorators()->addDecorator('Label', $labelSettings)->addDecorator('ViewHelper')->addDecorator('Description', array('escape' => false))->addDecorator('Errors')->addDecorator('Wrapper', array('tag' => 'div', 'id' => $elm->getName() . '-wrapper', 'class' => $class));
     if ($elm instanceof Zend_Form_Element_Submit) {
         $elm->removeDecorator('Label');
     }
 }