Hi,
I've been developing a poll form using zend.
I've created the form class to dynamically create the form with the poll
title, one or more questions and some choices (radio or checkbox) for every
question.
All form elements are zend_form_element except for the title and the
question elements for whom I've created this custom element:

class Default_Model_myXhtml extends Zend_Form_Element_Xhtml
{
        public $helper = 'formNote'; 
}


Here's the form class where basic and custom elements are initialized and
decorators removed to render the form with my custom form (poll-form.phtml):

class Default_Model_PollForm extends Zend_Form
{       
        public function __construct($options = null)
        {
                parent::__construct($options);
                
                ...
                
                $customElement = new Default_Model_myXhtml('title');
                $customElement->setValue('<p>POLL TITLE</p>');          
                $this->addElement($customElement);
                
                ...
                
                $this->setDecorators(array());
        
$this->addDecorator('ViewScript',array('viewScript'=>'index/poll-form.phtml')); 
        
        
                $this->removeDecorator('htmltag');              

                foreach ($this->getElements() as $element)
                {
                        $element->removeDecorator('label');
                        $element->removeDecorator('errors');
                        $element->removeDecorator('htmltag');
                        $element->removeDecorator('DtDdWrapper');
                }               
        }
}               


Then in the poll-form.phtml:

<form id="<?php echo $this->element->getName() ?>" 
                        action="<?php echo $this->element->getAction() ?>" 
                        method="<?php echo $this->element->getMethod() ?>">
        
        ...

        <div class="title">
        <?php echo $this->element->title ?>
        </div>
        
        ...
        
</form> 

                
The problem is that after validating the form, if the validation fails I see
the form with all basic elements except for my custom elements.
Is there a way to create custom html elements inside a zend form and make
them behave like other zend form elements?

Thanks
-- 
View this message in context: 
http://www.nabble.com/custom-form-element-not-shown-after-unsuccessful-form-validation-tp24512154p24512154.html
Sent from the Zend Framework mailing list archive at Nabble.com.

Reply via email to