form not found (hiérarchie model)
salut à tous,
je serai vraiment reconaissant si vous pouvez m’aider a propos d’un petit probeleme
Fatal error: Class 'Application_Form_Book' not found in D:\wamp\www\application\modules\admin\controllers\BookController.php on line 8
hiérarchie
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17
| >application
>configs
->application.ini
>layouts
> modules
> admin
> controllers
-> BookController.php
> forms
-> Book.php
> models
> DbTable
-> Book.php
> views
-> Bootstrap.php(1)
> default
-> Bootstrap.php(0) |
> admin
> controllers
-> BookController.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28
|
<?php
class Admin_BookController extends Zend_Controller_Action
{
function addAction()
{
$form = new Application_Form_Book();
$form->envoyer->setLabel('Ajouter');
$this->view->form = $form;
if ($this->getRequest()->isPost())
{
$formData = $this->getRequest()->getPost();
if ($form->isValid($formData)) {
$title = $form->getValue('title');
$author = $form->getValue('author');
$books = new Library_Model_ListBooks();
$books->addBook($title, $author);
$this->_helper->redirector('index');
} else {
$form->populate($formData);
}
}
}
} |
> admin
> models
> DbTable
-> Book.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15
| <?php
class Application_Model_DbTable_Books extends Zend_Db_Table_Abstract
{
protected $_name = 'Books';
public function addBook($title, $author)
{
$data = array(
'title' => $title,
'author' => $author,
);
$this->insert($data);
}
} |
> admin
> forms
-> Book.php
Code:
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31
| <?php
class Application_Form_Book extends Zend_Form
{
public function init()
{
$this->setName('Book');
$id = new Zend_Form_Element_Hidden('id');
$id->addFilter('Int');
$artiste = new Zend_Form_Element_Text('title');
$artiste->setLabel('Title')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$titre = new Zend_Form_Element_Text('author');
$titre->setLabel('Author')
->setRequired(true)
->addFilter('StripTags')
->addFilter('StringTrim')
->addValidator('NotEmpty');
$envoyer = new Zend_Form_Element_Submit('envoyer');
$envoyer->setAttrib('id', 'boutonenvoyer');
$this->addElements(array($id, $title, $author, $envoyer));
}
} |
merci d'avance