I'm trying to use components of the Framework in a project that currently is
not MVC. Eventually I'd like to refactor to MVC but that is not possible
right now.
I'm using Zend_Form and ran into an error that I can't figure out. I'm
trying to use the ViewScript decorator and I've read through the Decorators
with Zend Form arcticle and scoured the web but now I'm stuck.
The error I get is: *Warning: ViewHelper decorator cannot render without a
registered view object*
*Some code: formt_test.php (in tests folder and main script)*
require_once('Zend/View.php');
require_once('TestForm.php');
$form = new TestForm();
echo $form->render(new
Zend_View(array('basePath'=>'/path/to/tests/views')));
*TestForm.php*
require_once 'Zend/Form.php';
require_once 'Zend/Form/Element/Select.php';
class TestForm extends Zend_Form
{
public function init()
{
$this->setAction("/test_action");
$this->setMethod("post");
$statuses = array(
'Booked'=>'Booked',
'Cancelled'=>'Cancelled',
'Pending'=>'Pending',
);
$types = array(
'Public'=>'Public',
'Private'=>'Private'
);
$this->addElement(new Zend_Form_Element_Select('status'));
$this->addElement(new Zend_Form_Element_Select('event_type'));
$this->getElement('status')->addMultiOptions($statuses);
$this->getElement('event_type')->addMultiOptions($types);
$this->setDecorators(array(
array('ViewScript', array('viewScript'=>'test_form.phtml'))
));
}
}
*test_form.phtml*
<form action="<?= $this->escape($this->element->getAction()) ?>" method="<?=
$this->escape($this->element->getMethod()) ?>">
<fieldset>
<legend>Test Form</legend>
<table id='edit_test' style='width: 650px;'>
<tr>
<td class='edit_mem'>Event Status:<br /><?=
$this->element->status ?></td>
<td class='edit_mem'>Event Type:<br /><?=
$this->element->event_type ?></td>
</tr>
</table>
</fieldset>
</fieldset>
</form>
Any help would be greatly appreciated. Thanks in advance.