How does one add a 'plain text node' to a zend form?

后端 未结 7 560
夕颜
夕颜 2021-02-04 02:41

I\'m trying to add a plain text node in a zend form - the purpose is to only dispay some static text.

The problem is - im not aware of any such way to do it.

I

7条回答
  •  野的像风
    2021-02-04 03:09

    There might be a better way, but I created a paragraph by using a custom form element and view helper. Seems like alot of code for something so simple. Please let me know if you've found a more simplistic way to do it.

    //From your form, add the MyParagraph element
    $this->addElement(new Zend_Form_Element_MyParagraph('myParagraph'));
    
    class Zend_Form_Element_MyParagraph extends Zend_Form_Element
    {
        public $helper = 'myParagraph';
        public function init()
        {
            $view = $this->getView();
        }
    }
    
    class Zend_View_Helper_MyParagraph extends Zend_View_Helper_FormElement {
    
        public function init() {
        }
    
        public function myParagraph() {
            $html = '

    hello world

    '; return $html; } }

提交回复
热议问题