Advertisement
c00lways

Zend Form Element Separator

Oct 1st, 2012
145
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.90 KB | None | 0 0
  1. <?php
  2. //form element
  3. class EntStudio_Form_Element_Separator extends Zend_Form_Element_Xhtml {
  4.  
  5.   public $helper = 'FormSeparator';
  6.  
  7.   public function init() {
  8.     $this->removeDecorator("HtmlTag");
  9.     $this->removeDecorator("Label");
  10.     $this->removeDecorator("Description");
  11.     $this->setDecorators(array(
  12.       array('ViewHelper'),
  13.     ));
  14.   }
  15.  
  16. }
  17.  
  18. //helper class
  19. class EntStudio_View_Helper_FormSeparator {
  20.  
  21.   public function FormSeparator($name, $value = null, $attribs = null) {
  22.    
  23.     $sClass = "clear";
  24.     $sClass .= ! empty($attribs["class"]) ? " " . $this->escape($attribs["class"]): "";
  25.    
  26.     $xhtml = "<div class='" . $sClass . "'></div>";
  27.  
  28.     return $xhtml;
  29.   }
  30.  
  31. }
  32.  
  33. /**
  34. to use:
  35. $this->addElement("separator", "sep1", array(
  36.       "ignore" => true
  37.     ));
  38.  
  39. this creates:
  40. <div class="clear"></div>
  41. //makesure to add your own class .clear { clear:both; }
  42. **/
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement