00001 <?php 00026 require_once 'Zend/View/Helper/FormElement.php'; 00027 00028 00038 class Zend_View_Helper_FormErrors extends Zend_View_Helper_FormElement 00039 { 00043 protected $_element; 00044 00048 protected $_htmlElementEnd = '</li></ul>'; 00049 protected $_htmlElementStart = '<ul%s><li>'; 00050 protected $_htmlElementSeparator = '</li><li>'; 00060 public function formErrors($errors, array $options = null) 00061 { 00062 $escape = true; 00063 if (isset($options['escape'])) { 00064 $escape = (bool) $options['escape']; 00065 unset($options['escape']); 00066 } 00067 00068 if (empty($options['class'])) { 00069 $options['class'] = 'errors'; 00070 } 00071 00072 $start = $this->getElementStart(); 00073 if (strstr($start, '%s')) { 00074 $attribs = $this->_htmlAttribs($options); 00075 $start = sprintf($start, $attribs); 00076 } 00077 00078 if ($escape) { 00079 foreach ($errors as $key => $error) { 00080 $errors[$key] = $this->view->escape($error); 00081 } 00082 } 00083 00084 $html = $start 00085 . implode($this->getElementSeparator(), (array) $errors) 00086 . $this->getElementEnd(); 00087 00088 return $html; 00089 } 00090 00097 public function setElementEnd($string) 00098 { 00099 $this->_htmlElementEnd = (string) $string; 00100 return $this; 00101 } 00102 00108 public function getElementEnd() 00109 { 00110 return $this->_htmlElementEnd; 00111 } 00112 00119 public function setElementSeparator($string) 00120 { 00121 $this->_htmlElementSeparator = (string) $string; 00122 return $this; 00123 } 00124 00130 public function getElementSeparator() 00131 { 00132 return $this->_htmlElementSeparator; 00133 } 00134 00141 public function setElementStart($string) 00142 { 00143 $this->_htmlElementStart = (string) $string; 00144 return $this; 00145 } 00146 00152 public function getElementStart() 00153 { 00154 return $this->_htmlElementStart; 00155 } 00156 00157 }