How to set input value from view in Zend Framework 2

Hi guys! Today I will explain to you how you can set input value from view in Zend Framework 2. As you might know, you can easily set value from your form model.

If you want to set input value or textarea value from view, you must write this code:


$element = $form->get('inputname');
$element->setValue("Something");
echo $this->formInput($element);
echo $this->formElementErrors($form->get('inputname'));

instead


echo $this->formInput($form->get('inputname')) . $this->formElementErrors($form->get('inputname'));

Video tutorial:









Leave a Comment