How to use a custom Zend Framework form in a directory inside application
I have a "forms" directory inside my application directory with custom form php files in there. In my application.ini the appnamespace is "Application". 开发者_StackOverflow社区 The form name I'm trying to use is BetaSignup.php. The class is Application_Form_BetaSignup.
In my controller I try to do $form = new Application_Form_BetaSignup
, and I get an error saying:
Fatal error: Class 'Application_Form_BetaSignup' not found.
Thoughts on how to fix?
You can use the typical application/forms
directory for your form classes if you name them appropriately using the configured appnamespace
directive (default "Application"). Please note, the directory name is lowercase "forms".
For example, say you have a registration form "Registration". Create the file at application/forms/Registration.php
(note the case sensitivity) containing the class
class Application_Form_Registration extends Zend_Form
{
// etc
The resource autoloader will be able to find your form when you instantiate it in your controllers, eg
$form = new Application_Form_Registration(); // will be auto-loaded
精彩评论