📜 ⬆️ ⬇️

Arbitrary html code in Zend_Form

There was such a task today in the process of working on one project. But nowhere could not find a solution.
You can frame the form using Zend_Form_Decorator_HtmlTag , but you can’t just paste the code.
Zend_Form_Decorator_HtmlTag, when created, receives a tag variable, for example td, and returns something like the following:
...
And if you remove the closing tag, and from the first remove the triangular brackets?
Thought went ...

And I developed Zend_Form_Decorator_HtmlCode ( you can download it here ).

Now in Zend_Form_Element we can add our decorator.
')
$code = ' ';
$elementDecorators = array(
array('decorator' => array('br' => 'HtmlCode'), 'options' => array('tag' => $code, 'placement' => Zend_Form_Decorator_Abstract::APPEND)),
);
$this -> addDecorators($elementDecorators);


Now after the form element appears $ code.

Source: https://habr.com/ru/post/50068/


All Articles