1

I'm trying to use forms with modules, they should be stored inside the module. So at first my filestructure:

application/ (...other directories) modules/ group/ controllers/ IndexController.php (...controllers) forms/ Create.php views/ scripts/ (...view scripts) Bootstrap.php 

Within the IndexController, I'm trying to set the Form by

new Group_Form_Create() 

and the class in Create.php is of course Group_Form_Create. I get the following error message:

Fatal error: Class 'Group_Form_Create' not found in (...)\application\modules\group\controllers\IndexController.php on line 380 

The Bootstrap.php with the class Group_Bootstrap is just an empty class. Actually, I'm using the default Zend structure, but it woun't work anyway. Any ideas wheres the problems or what could be a possible solution?

3 Answers 3

3

In my module bootstrap (APPLICATION_PATH/modules/group/Bootstrap.php), if use the following code:

 //Loads the autoloader resources $this->_moduleName = 'group'; $resourceLoader = new Zend_Loader_Autoloader_Resource(array( 'basePath' => APPLICATION_PATH ."/modules/".$this->_moduleName."/", 'namespace' => '', 'resourceTypes' => array( //Tells the application where to find the forms 'form' => array( 'path' => 'forms/', 'namespace' => ucfirst($this->_moduleName).'_Form_' ), //Tells the application where to find the models 'model' => array( 'path' => 'models/', 'namespace' => ucfirst($this->_moduleName).'_Model_' ) ) )); 

I then call the forms or models like this:

$frm = new Group_Form_Create(); 

I use the same snippet in all my modules and I only change the value of the $this->_moduleName; each time.

Hope this helps !

Sign up to request clarification or add additional context in comments.

2 Comments

Same problem here: The site is gonna be an high-performance system with not only one module and the Group_Bootstrap is for some reason not executed. Any idea why?
In you main ini config file, did you add the line resources.modules="" ?
1

It sounds like your module bootstraps are not being run. These are triggered by the module resource, which is loaded if you have:

resources.modules[] = "" 

in your application.ini. So add this if it is not present.

1 Comment

That's it, thank you ;-) Consider your answer as my accepted answer, even if the main point of my problem was something different, it really helped me out!
0

Ideally, it should work out of box.

Add this in your bootstrap:

protected function _initAutoload() { $autoloader = new Zend_Application_Module_Autoloader(array( 'namespace' => 'Group_', 'basePath' => dirname(__FILE__), )); Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true); return $autoloader; 

}

1 Comment

Works with APPLICATION_PATH . '/modules/group/' as basePath, but only in the main bootstrap, not in the one of the module. Any ideas how to bring this to work in the Group_Bootstrap? Would be much better for the performance. I suppose the Group_Bootstrap is just unused...

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.