Frage

I am getting the following error :
 Fatal error: Class 'Application_Form_Employee' not found in /var/www/Employee/application/controllers/EmployeeController.php on line 31 

I have created a separate folder for the forms in applications and placed the form Employee.php in the folder of Employee which is inside Forms . The routing in the application.ini is shown below : resources.router.routes.employee.route = /employee

      resources.router.routes.employee.defaults.module = default           

  resources.router.routes.employee.defaults.controller = Employee

  resources.router.routes.employee.defaults.action = new  
   resources.router.routes.employee.route = /employee

resources.router.routes.employee.defaults.module = default           

resources.router.routes.employee.defaults.controller = Employee

resources.router.routes.employee.defaults.action = edit
resources.router.routes.employee.route = /employee

resources.router.routes.employee.defaults.module = default           

resources.router.routes.employee.defaults.controller = Employee

 resources.router.routes.employee.defaults.action = index

Please specify if any additional information required ///////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////////// P.S : I have tried to solve this error in a thousand ways by changing the folders and routing.

War es hilfreich?

Lösung

To enable forms simply and to correctly configure the resource, use the Zend_Tool cli.

At your command line or if your ide is compable (Netbeans is) enter the command:

zf enable form

this will create the correct directory for application level and Application namespaced forms.

When using application level forms the class name will be prefixed with Application_Form_ and the file will exist at

/application
    /forms
        /Myform.php

If you need forms in a module simply alter the command to reflect the module name:

zf enable form -m admin

almost all commands in Zend_Tool cli can use the -m switch to specify a module name.

ZF1 has a number of predefine resources that have their own namespaces the class Zend_Application_Module_Autoloader has a complete list of the default namespaces along with the default path for each.

This answer assumes your application setup is reasonably close to a default ZF1 configuration.

P.S. I noticed that all of your routes have the same name 'employee'. If you want each of these routes to actually work, they need different names. The individual urls should work but the 'named' routes won't. Only the last route in the stack will work.

for example:

//4 lines equals one route
resources.router.routes.employee.route = /employee
resources.router.routes.employee.defaults.module = default           
resources.router.routes.employee.defaults.controller = Employee
resources.router.routes.employee.defaults.action = index


//this route might work better as
resources.router.routes.editEmployee.route = /employee/edit
resources.router.routes.editEmployee.defaults.module = default           
resources.router.routes.editEmployee.defaults.controller = Employee
resources.router.routes.editEmployee.defaults.action = edit

each 'named' route should have a unique name and a unique url.

Andere Tipps

You should not name your form class Application_Form_Employee.

It should be named Form_Employee. You should never prepend your class with Application in Zend.

For example, a model located inside application/Models/Test.php should be named Model_Test and not Application_Model_Test. Same for forms, services...

Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top