-- Friedhelm Betz <[EMAIL PROTECTED]> wrote
(on Tuesday, 01 April 2008, 03:58 PM +0200):
> Newbie question about hidden fields default rendering (ZF 1.5.0).
>
> My simple, standalone form:
>
> <?php
> require_once('Zend/Loader.php');
> Zend_Loader::registerAutoload();
> $form = new Zend_Form();
> $form->setAction('foo.php');
> $form->addElement('hidden', 'foo', array('values' => 'foobar'))
>          ->addElement('text', 'username', array('label' => 'username'))
>          ->addElement('password', 'password', array('label' => 'password'))
>          ->addElement('submit', 'login');
> $form->setView(new Zend_View());
> echo $form;
> ?>
>
> The hidden field renders with self-closing tag:
> <input type="hidden" name="foo" value="" values="foobar" id="foo" />
>
> other fields render without self-closing tag (for example):
> <input type="text" name="username" id="username" value="">
>
> This happens also with Zend_Form_Element_Hash.
>
> Is this expected behavior? At least, it seems inconsistent to me.

Two things are at play, here.

First, form view helpers are doctype aware. The default doctype is
HTML4_LOOSE, so that means now closing tag. However, if you set an
alternate doctype early in execution, prior to rendering your form, you
can change this behavior.

Second, the formHidden() helper is currently *not* doctype aware, and
this has already been reported:

    http://framework.zend.com/issues/browse/ZF-2958

It will be fixed in an upcoming release.

-- 
Matthew Weier O'Phinney
PHP Developer            | [EMAIL PROTECTED]
Zend - The PHP Company   | http://www.zend.com/

Reply via email to