Matthew Weier O'Phinney wrote:
-- Friedhelm Betz <[EMAIL PROTECTED]> wrote
(on Tuesday, 01 April 2008, 08:02 PM +0200):
Holger Lampe wrote:
Other view form helpers check for a set XHTML doctype. FormHidden
depends on the _hidden function in the FormElement class, which does
not check the doctype.
Thanks for the hint.
I patched my install of ZF to make hidden fields doctype aware ;-)
Care to save me the work and contribute it back? ;-)
Sure, if this saves you any time: patch against trunk attached ;-)
Friedhelm
p.s.: inline, if attachments don't get through.
Index: FormElement.php
===================================================================
--- FormElement.php (revision 9107)
+++ FormElement.php (working copy)
@@ -182,10 +182,18 @@
*/
protected function _hidden($name, $value = null, $attribs = null)
{
- return '<input type="hidden"'
- . ' name="' . $this->view->escape($name) . '"'
- . ' value="' . $this->view->escape($value) . '"'
- . $this->_htmlAttribs($attribs) . ' />';
+ $endTag = ' />';
+ if (($this->view instanceof Zend_View_Abstract) &&
!$this->view->doctype()->isXhtml()) {
+ $endTag= '>';
+ }
+
+ $xhtml = '<input type="hidden"'
+ . ' name="' . $this->view->escape($name) . '"'
+ . ' value="' . $this->view->escape($value) . '"'
+ . $this->_htmlAttribs($attribs)
+ . $endTag;
+
+ return $xhtml;
}
/**
Index: FormElement.php
===================================================================
--- FormElement.php (revision 9107)
+++ FormElement.php (working copy)
@@ -182,10 +182,18 @@
*/
protected function _hidden($name, $value = null, $attribs = null)
{
- return '<input type="hidden"'
- . ' name="' . $this->view->escape($name) . '"'
- . ' value="' . $this->view->escape($value) . '"'
- . $this->_htmlAttribs($attribs) . ' />';
+ $endTag = ' />';
+ if (($this->view instanceof Zend_View_Abstract) &&
!$this->view->doctype()->isXhtml()) {
+ $endTag= '>';
+ }
+
+ $xhtml = '<input type="hidden"'
+ . ' name="' . $this->view->escape($name) . '"'
+ . ' value="' . $this->view->escape($value) . '"'
+ . $this->_htmlAttribs($attribs)
+ . $endTag;
+
+ return $xhtml;
}
/**