Autloading modular forms & models in Zend Framework 1.8
It’s not really obvious with the error messages you get, but using a thing like Form_Login does not work out of the box with a modular structure. Which is slightly surprising considering that it’s inside the default module.
I have found examples like the second one below, but no one mentions that you actually declare the default namespace too for everything to work.
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => '',
'basePath' => APPLICATION_PATH .'/modules/default',
'resourceTypes' => array (
'form' => array(
'path' => 'forms',
'namespace' => 'Form',
),
'model' => array(
'path' => 'models',
'namespace' => 'Model',
),
)
));
$autoloader = new Zend_Application_Module_Autoloader(array(
'namespace' => 'Admin_',
'basePath' => APPLICATION_PATH .'/modules/admin',
'resourceTypes' => array (
'form' => array(
'path' => 'forms',
'namespace' => 'Form',
),
'model' => array(
'path' => 'models',
'namespace' => 'Model',
),
)
));
You can leave a response, or trackback from your own site.
Next Article
Previous Article
Add Comment
3
Comments


at 4:34 pm
Hi, I have a forms folder in the application directory and did not know how to include forms in the application.ini file.
So looking at your example did this
$moduleLoader = new Zend_Application_Module_Autoloader(array(
‘namespace’ => ”,
‘basePath’ => APPLICATION_PATH,
‘resourceTypes’ => array (
‘form’ => array(
‘path’ => ‘forms’,
‘namespace’ => ”,
)
)));
return $moduleLoader;
my name space is ” as I have my login form under forms folder /application/forms/LoginForm.php
I am still not having luck showing my forms.
thanks,
at 5:54 pm
Hi, I’d love to help but you’d need to provide a bit more detail about what is it that you are having trouble with, and if you are geting any errors…
at 1:23 am
Thanks a lot mate. it saved my hours.