Hallo Leute,
mein Crontroller findet leider meine Form_ Klasse nicht. Bin am Ende mit dem Latein, weil ich den Zend_Application_Module_Autoloader benutze.
ZF-Version: 1.9.6
Die Meldung:
PHP-Code:
Fatal error: Class 'Form_Post' not found in /var/www/dcTest/application/controllers/PostsController.php on line 59
PHP-Code:
// application/Bootstrap.php
protected function _initAutoload()
{
$moduleLoader = new Zend_Application_Module_Autoloader(
array(
'namespace' => '',
'basePath' => APPLICATION_PATH
)
);
// Füge RessourceTypes hinzu
//$moduleLoader->addResourceType('acl', 'acls/', 'Acl');
//$moduleLoader->addResourceType('form', 'forms/', 'Form');
//$moduleLoader->addResourceType('model', 'models/');
return $moduleLoader;
}
und der Controller
PHP-Code:
// application/controller/PostsController.php
class PostsController extends Zend_Controller_Action
{
public function addAction ()
{
// action body
//if (! Zend_Auth::getInstance()->hasIdentity()) {
//$this->_redirect('index/login');
//}
$request = $this->getRequest();
$postForm = new Form_Post();
if ($this->getRequest()->isPost()) {
if ($postForm->isValid($request->getPost())) {
$model = new Model_DbTable_Posts();
$model->savePost($postForm->getValues());
$this->_redirect('index/index');
}
}
$this->view->postForm = $postForm;
}
}
PHP-Code:
// application/forms/Posts.php
class Form_Post extends Zend_Form
{
public function __construct($options = array())
{
// parent ...
parent::__construct($options);
// form name
$this->setName('Posts');
// id
$id = new Zend_Form_Element_Hidden('id');
// title
$title = new Zend_Form_Element_Text('Title');
$title->setLabel('Title');
$title->setRequired(true);
$title->addFilter('StripTags');
$title->addFilter('StringTrim');
$title->addValidator('NotEmpty');
// description
$description = new Zend_Form_Element_Textarea('Description');
$description->setLabel('Description');
$description->setRequired(true);
$description->setAttrib('rows',20);
$description->setAttrib('cols',50);
$description->addFilter('StripTags');
$description->addFilter('StringTrim');
$description->addValidator('NotEmpty');
// submit
$submit = new Zend_Form_Element_Submit('submit');
$submit->setAttrib('id', 'submitbutton');
// add the elements
$this->addElements( array( $id, $title, $description, $submit ));
}
}
Hier die Struktur
Code:
.
|-- application
| |-- Bootstrap.php
| |-- configs
| | `-- application.ini
| |-- controllers
| | |-- ErrorController.php
| | |-- IndexController.php
| | `-- PostsController.php
| |-- forms
| | |-- Comments.php
| | |-- Login.php
| | `-- Posts.php
| |-- layouts
| | `-- scripts
| | `-- layout.phtml
| |-- models
| | |-- Acl.php
| | |-- AuthAdapter.php
| | `-- DbTable
| | |-- Comments.php
| | |-- Posts.php
| | `-- Users.php
| `-- views
| |-- helpers
| | |-- BaseUrl.php
| | |-- LinkTo.php
| | `-- LoggedInUser.php
| `-- scripts
| |-- error
| | `-- error.phtml
| |-- index
| | |-- index.phtml
| | |-- login.phtml
| | `-- logout.phtml
| |-- partials
| | `-- my_pagination_control.phtml
| `-- posts
| |-- add.phtml
| |-- edit.phtml
| |-- index.phtml
| `-- view.phtml
|-- library
| |-- DreamCoder
| `-- Zend -> ../../lib/ZendFramework-1.9.6/library/Zend/
|-- public
| |-- css
| | `-- blueprint
| | |-- ie.css
| | |-- plugins
| | | |-- buttons
| | | | |-- icons
| | | | | |-- cross.png
| | | | | |-- key.png
| | | | | `-- tick.png
| | | | |-- readme.txt
| | | | `-- screen.css
| | | |-- fancy-type
| | | | |-- readme.txt
| | | | `-- screen.css
| | | |-- link-icons
| | | | |-- icons
| | | | | |-- doc.png
| | | | | |-- email.png
| | | | | |-- external.png
| | | | | |-- feed.png
| | | | | |-- im.png
| | | | | |-- pdf.png
| | | | | |-- visited.png
| | | | | `-- xls.png
| | | | |-- readme.txt
| | | | `-- screen.css
| | | `-- rtl
| | | |-- readme.txt
| | | `-- screen.css
| | |-- print.css
| | |-- screen.css
| | `-- src
| | |-- forms.css
| | |-- grid.css
| | |-- grid.png
| | |-- ie.css
| | |-- print.css
| | |-- reset.css
| | `-- typography.css
| |-- index.php
| `-- info.php
`-- tests
|-- application
| |-- bootstrap.php
| `-- controllers
| |-- GuestbookControllerTest.php
| `-- PostsControllerTest.php
|-- library
| `-- bootstrap.php
`-- phpunit.xml
Vielen Dank für eure Hilfe im voraus
Lesezeichen