Answer the question
In order to leave comments, you need to log in
Zend Form and adding custom divs to the form
Zend_Form creates a form.
It can be displayed in a view in one line
<?php echo $this->myform;?>
. But a situation arose when, in addition to standard elements, several divs must be inserted into the form.
How can you correctly add any html elements to the form?
There is an option to display in the view element by element using renderViewHelper () and insert your own div in the right place, but in my opinion this is not good.
Answer the question
In order to leave comments, you need to log in
I myself somehow faced a similar problem. As a result, wrote Zend_Form_Decorator_HtmlTag. Here is an article from that time: Arbitrary html code in Zend_Form
What will be inside the div? Have you tried using decorators on elements?
function loadDefaultDecorators() {
parent::loadDefaultDecorators();
$this->setElementDecorators(array(
'ViewHelper',
'Description',
'Errors',
array('HtmlTag', array('tag' => 'p')),
array('Label', array('tag' => 'p')),
array(array('row' => 'HtmlTag'), array('tag' => 'div'))
));
foreach ($this->getElements() as $element) {
if ('Zend_Form_Element_Submit' == $element->getType()) {
$element->setDecorators(array(
'ViewHelper',
'Description',
'Errors',
array(array('row' =>
'HtmlTag'), array('tag' => 'div')) ));
}
if ('Zend_Form_Element_Hidden' == $element->getType()) {
$element->setDecorators(array(
'ViewHelper',
));
}
}
}
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question