(on Tuesday, 05 August 2008, 12:29 PM -0700):
> why the second hidden element will be created twice?
>
> class EventForm extends My_Form {
>
> public function init() {
>
> $this->addHiddenElement('ID');
> $this->addHiddenElement('PARENT_ID');
> }
> }
<snip>
> /**
> * builds a hidden element and adds it to the 'hiddenFields' display
> group
> * if the display group does not yet exists, it will be created
> */
> public function addHiddenElement($fp_sName, $fp_aOptions = null) {
>
> $oHidden = $this->createElement('hidden', $fp_sName, $fp_aOptions);
> $oHidden->setDecorators($this->_aHiddenDecorators);
> $this->addElement($oHidden);
>
> if($this->getDisplayGroup('hiddenFields')) {
> $this->getDisplayGroup('hiddenFields')->addElement($oHidden);
> } else {
> $this->addDisplayGroup(array($oHidden->getName()),
> 'hiddenFields', array(
> 'decorators' => $this->_aHiddenGroupDecorators,
> ));
> }
The issue is that display groups don't currently have support for adding
elements _after_ creation. There is an issue asking for this, but I've
postponed it for now as it's a non-trivial change that would require
giving display groups knowledge of their owning form.
(There's also an issue on file to group all hidden fields separately
when rendering so that they don't create whitespace, but that's also on
hold for similar reasons.)
A better way to do this would be to aggregate the names of all hidden
elements, and then at rendering time create your display group.
> }
>
> <form enctype="application/x-www-form-urlencoded" action=".." method="post">
>
> <input type="hidden" name="ID" value="" id="ID">
> <input type="hidden" name="PARENT_ID" value="" id="PARENT_ID">
> <input type="hidden" name="PARENT_ID" value="" id="PARENT_ID">
>
> </form>
--
Matthew Weier O'Phinney
Software Architect | matthew@zend.com
Zend Framework | http://framework.zend.com/
没有评论:
发表评论