Hi to everyone, i have a strange problem with Zend_Form and Decorators. I
have to implement a form in which every element and the corresponding label
must be surrounded by a table row and with label and element in their
respective cells, so i extended the Zend_Form class and in the constructor i
wrote this:

$this->setElementDecorators(
        array (
                array ('ViewHelper'), 
                array ('Errors'), 
                array ('HtmlTag', array ('tag' => 'td')), 
                array ('Label', array ('tag' => 'td')), 
                array (
                        'decorator' => array ('TableRow' => 'HtmlTag'), 
                        'options' => array ('tag' => 'tr'))));

and the this thing works fine, but i've a problem with rendering of buttons.
My submit and reset buttons live in a display group and they are always the
same, so i added a method in my form subclass that add this display group
with the two buttons in this way:

        protected function addSubmitButton($label = 'Send') {
                $submit = new Zend_Form_Element_Submit('submitBtn', $label);
                $reset = new Zend_Form_Element_Reset('resetBtn', 'Reset');
                $submit->setDecorators(array ('ViewHelper'));
                $reset->setDecorators(array ('ViewHelper'));
                $this->addElement($submit);
                $this->addElement($reset);
                Zend_Debug::dump($submit->render());
                parent::addDisplayGroup(array ('submitBtn', 'resetBtn'), 
'buttons');
                $grp = $this->getDisplayGroup('buttons');
                $grp->setOptions(
                                array (
                                                'legend' => 'Send Form', 
                                                'disableLoadDefaultDecorators' 
=> true));
                Zend_Debug::dump($submit->render());
        }

but when the buttons are rendered default decorators set with
setElementDecorators are used. I don't understand why, since I've used
setDecorators in my addSubmitButton method and the two Zend_Debug calls in
that method report correctly:

string(76) "
<input type="submit" name="submitBtn" id="submitBtn" value="Send" />"

string(76) "
<input type="submit" name="submitBtn" id="submitBtn" value="Send" />"

Suggestion?

Thanks.
-- 
View this message in context: 
http://www.nabble.com/Zend_Form-and-setElementDecorators-usage-tp16951201p16951201.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to