Witaj Gościu! ( Zaloguj | Rejestruj )

Forum PHP.pl

> [ZF] formsy i fatal error :|, poczatkujacy
matchor
post
Post #1





Grupa: Zarejestrowani
Postów: 46
Pomógł: 0
Dołączył: 1.05.2005

Ostrzeżenie: (0%)
-----


Fatal error: Class 'forms_ContactForm' not found in /xxx/application/controllers/RegisterController.php on line 38
mam takie pliki w takich lokalizacjach
  1. /xxx/application/forms/ContactForm
  2. /xxx/public/index.php
  3. /xxx/controllers/RegisterController.php


=============================
/xxx/application/forms/ContactForm
  1. <?php
  2.  
  3. class forms_ContactForm extends Zend_Form
  4. {
  5. public function __construct($options = null)
  6. {
  7. parent::__construct($options);
  8. $this->setName('contact_us');
  9.  
  10. $title = new Zend_Form_Element_Select('title');
  11. $title->setLabel('Title')
  12. ->setMultiOptions(array('mr'=>'Mr', 'mrs'=>'Mrs'))
  13. ->setRequired(true)->addValidator('NotEmpty', true);
  14.  
  15. $firstName = new Zend_Form_Element_Text('firstName');
  16. $firstName->setLabel('First name')
  17. ->setRequired(true)
  18. ->addValidator('NotEmpty');
  19.  
  20. $lastName = new Zend_Form_Element_Text('lastName');
  21. $lastName->setLabel('Last name')
  22. ->setRequired(true)
  23. ->addValidator('NotEmpty');
  24.  
  25. $email = new Zend_Form_Element_Text('email');
  26. $email->setLabel('Email address')
  27. ->addFilter('StringToLower')
  28. ->setRequired(true)
  29. ->addValidator('NotEmpty', true)
  30. ->addValidator('EmailAddress');
  31.  
  32.  
  33. $submit = new Zend_Form_Element_Submit('submit');
  34. $submit->setLabel('Contact us');
  35.  
  36. $this->addElements(array($title, $firstName,
  37. $lastName, $email, $submit));
  38.  
  39. }
  40. }



=============================
/xxx/controllers/RegisterController.php
  1. public function indexAction()
  2. {
  3.  
  4. $form = new forms_ContactForm(); // <========= tu sie wykrzacza



=============================

/xxx/public/index.php :

  1. <?php
  2. // Set the initial include_path. You may need to change this to ensure that
  3. // Zend Framework is in the include_path; additionally, for performance
  4. // reasons, it's best to move this to your web server configuration or php.ini
  5. // for production.
  6. set_include_path(implode(PATH_SEPARATOR, array(
  7. realpath(dirname(__FILE__) . '/../library'),
  8. )));
  9.  
  10. // Define path to application directory
  11. defined('APPLICATION_PATH')
  12. || define('APPLICATION_PATH', realpath(dirname(__FILE__) . '/../application'));
  13.  
  14. // Define application environment
  15. defined('APPLICATION_ENV')
  16. || define('APPLICATION_ENV', (getenv('APPLICATION_ENV') ? getenv('APPLICATION_ENV') : 'production'));
  17.  
  18. /** Zend_Application */
  19. require_once 'Zend/Application.php';
  20.  
  21. // Create application, bootstrap, and run
  22. $application = new Zend_Application(
  23. APPLICATION_ENV,
  24. APPLICATION_PATH . '/configs/application.ini'
  25. );
  26. $application->bootstrap();
  27. $application->run();
Go to the top of the page
+Quote Post
 
Start new topic
Odpowiedzi (1 - 9)
nospor
post
Post #2





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




zgodnie z dokumentacją zenda i ich autoloadera:

nie: /xxx/application/forms/ContactForm
a: /xxx/application/forms/Contact.php

nie: class forms_ContactForm extends Zend_Form
a: class Form_Contact extends Zend_Form

nie: $form = new forms_ContactForm();
a: $form = new Form_Contact();


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
matchor
post
Post #3





Grupa: Zarejestrowani
Postów: 46
Pomógł: 0
Dołączył: 1.05.2005

Ostrzeżenie: (0%)
-----


zrobilem jak piszesz ale nie pomoglo:

  1. Fatal error: Class 'Form_Contact' not found in /xxx/application/controllers/RegisterController.php on line 38
Go to the top of the page
+Quote Post
nospor
post
Post #4





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Napewno zastosowałeś się do wszystkich trzech rzeczy? Pokaż teraz wszystko jak u Ciebie wygląda: struktura plikow, nazwa pliku i zawartosc i wywołanie


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
nospor
post
Post #5





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




kurcze.........................................
przeciez WYRAŹNIE napisałem:
class Form_Contact extends Zend_Form


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
matchor
post
Post #6





Grupa: Zarejestrowani
Postów: 46
Pomógł: 0
Dołączył: 1.05.2005

Ostrzeżenie: (0%)
-----


i tak jest w

Contact.php:
  1.  
  2. class Form_Contact extends Zend_Form
  3. {
  4. public function __construct($options = null)
  5. {
  6. parent::__construct($options);
  7. $this->setName('contact_us');
  8.  
  9. $title = new Zend_Form_Element_Select('title');
  10. $title->setLabel('Title')
  11. ->setMultiOptions(array('mr'=>'Mr', 'mrs'=>'Mrs'))
  12. ->setRequired(true)->addValidator('NotEmpty', true);
  13.  
  14. $firstName = new Zend_Form_Element_Text('firstName');
  15. $firstName->setLabel('First name')
  16. ->setRequired(true)
  17. ->addValidator('NotEmpty');
  18.  
  19. $lastName = new Zend_Form_Element_Text('lastName');
  20. $lastName->setLabel('Last name')
  21. ->setRequired(true)
  22. ->addValidator('NotEmpty');
  23.  
  24. $email = new Zend_Form_Element_Text('email');
  25. $email->setLabel('Email address')
  26. ->addFilter('StringToLower')
  27. ->setRequired(true)
  28. ->addValidator('NotEmpty', true)
  29. ->addValidator('EmailAddress');
  30.  
  31.  
  32. $submit = new Zend_Form_Element_Submit('submit');
  33. $submit->setLabel('Contact us');
  34.  
  35. $this->addElements(array($title, $firstName,
  36. $lastName, $email, $submit));
  37.  
  38. }
  39. }
  40.  

Go to the top of the page
+Quote Post
nospor
post
Post #7





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




Cytat
i tak jest w
tja... tylko ze w poprzednim poscie, który notabene już edytowałeś, napisałes:
class Form_ContactForm extends Zend_Form

stąd moje podirytowanie smile.gif

Wiec dziala już? A jak nie działa to napewno masz dokładnie tak jak teraz podajesz?


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
matchor
post
Post #8





Grupa: Zarejestrowani
Postów: 46
Pomógł: 0
Dołączył: 1.05.2005

Ostrzeżenie: (0%)
-----


edytowalem bo wkleilem zle;)

tak jest dokladnie to co mam na serwerze i wciaz mam

  1. Fatal error: Class 'Form_Contact' not found in /xxx/application/controllers/RegisterController.php on line 38


nie wiem za bardzo co jest problem jzu kombinowalem roznie - obstawialem ze moze sciezki w index.php :|
Go to the top of the page
+Quote Post
nospor
post
Post #9





Grupa: Moderatorzy
Postów: 36 557
Pomógł: 6315
Dołączył: 27.12.2004




to spróbuj jeszcze ustawić autoloadera:
http://framework.zend.com/manual/en/zend.l...r-resource.html

choć domyślnie tam jest napisane, że ten autoloader dla formsów jest ustawiony.


--------------------

"Myśl, myśl, myśl..." - Kubuś Puchatek || "Manual, manual, manual..." - Kubuś Programista
"Szukaj, szukaj, szukaj..." - Kubuś Odkrywca || "Debuguj, debuguj, debuguj..." - Kubuś Developer

Go to the top of the page
+Quote Post
matchor
post
Post #10





Grupa: Zarejestrowani
Postów: 46
Pomógł: 0
Dołączył: 1.05.2005

Ostrzeżenie: (0%)
-----


w Bootstrap mialem juz ustawionego Autoloadera

  1. protected function _initAutoload()
  2. {
  3. $autoloader = new Zend_Application_Module_Autoloader(array(
  4. 'namespace' => 'Default',
  5. 'basePath' => dirname(__FILE__),
  6. ));
  7. return $autoloader;
  8. }


klase musialem zdeklarowac

class Default_Form_Contact extend ...

  1. $form = new Default_Form_Contact();
Go to the top of the page
+Quote Post

Reply to this topicStart new topic
1 Użytkowników czyta ten temat (1 Gości i 0 Anonimowych użytkowników)
0 Zarejestrowanych:

 



RSS Aktualny czas: 20.08.2025 - 13:26