Witam, mam problem z formularzami w ZF2. Jako, że dopiero zaczynam, nie wiem gdzie znajduje się błąd.
Strukturę katalogów mam domyślną.
Oto model:
<?php
namespace Example;
use Zend\Mvc\ModuleRouteListener;
class Module
{
public function getConfig()
{
return include __DIR__ . '/config/module.config.php';
}
public function getAutoloaderConfig()
{
'Zend\Loader\StandardAutoloader' => array( __NAMESPACE__ => __DIR__ . '/src/' . __NAMESPACE__,
),
),
);
}
}
Tutaj controller:
<?php
namespace Example\Controller;
use Zend\Mvc\Controller\AbstractActionController;
use Zend\View\Model\ViewModel;
use Zend\Form\Form;
use Zend\Form\Fieldset;
class IndexController extends AbstractActionController
{
public function indexAction()
{
require_once 'form_add.php';
$form = new forms_Formularz();
$this->view->form = $form;
return new ViewModel();
}
}
A tutaj sam formularz:
<?php
namespace Example\Form;
use Zend\Form\Form;
class forms_Formularz extends Zend_Form
{
public function init()
{
$firstname = new Zend_Form_Element_Text('firstname');
$lastname = new Zend_Form_Element_Text('lastname');
$position = new Zend_Form_Element_Select('position');
$description = new Zend_Form_Element_Textarea('description');
$submit = new Zend_Form_Element_Submit('btn-submit');
$this->addElement($firstname);
$this->addElement($lastname);
$this->addElement($position);
$this->addElement($description);
$this->addElement($submit);
}
}
?>
Błąd brzmi:
Fatal error: Class 'Zend_Form' not found in E:\www\zf\module\Example\src\Example\Controller\form_add.php on line 3
Proszę o pomoc, z góry dzięki.
Widok myślę, że jest zbędny.