0

$emailmessage = new Zend_Form_Element_Hidden('emailmessage');

the hidden filed value, i.e 'emailmessage' retrieves the value of the same field name inside the database. However on loading the page, value of the 'emailmessage' cannot be seen, since the element is hidden. Is there any way to display it without using any other form elements. I want it without using text, textarea, etc.

vinay vyas
  • 491
  • 1
  • 4
  • 17

2 Answers2

0

in controller you need to assign it to view and in the view you can echo it where ever you want:

controller

$form = new Your_Form();
$this->view->emailmessage = $emailmessage;

View

echo $this->escape($this->emailmessage);
000
  • 3,976
  • 4
  • 25
  • 39
  • $emailsms is a part of a form that im displaying to the view via "$this->form; " Elaborating my query, what i need to do is, Display plain text on my form. – vinay vyas Aug 24 '12 at 06:26
  • the answer above is to Display plain text on form..also check [this post](http://stackoverflow.com/questions/2566432/add-some-html-to-zend-forms)..it might be what you are looking.. – 000 Aug 24 '12 at 06:34
  • Thanks Rishi. I resolved the problem by including form element "Textarea" and removed borders and added readonly property of html so that the field appears as plain text, and cannot be modified. – vinay vyas Aug 24 '12 at 11:09
0

You need to set formNote decorator for the element. You do it by extending Hidden element or by setting decorator in the form.

Form

public function init()
{
    // ...
    $emailMessage = new Zend_Form_Element_Hidden();
    $emailMessage->setDecorators(
        array(
            array('ViewHelper', array('helper' => 'formNote'))
        )
    );
    $this->addElement($emailMessage, 'emailMessage');
    // ...
}
ainokna
  • 855
  • 10
  • 18