dsa1230000 2013-03-22 09:57
浏览 18
已采纳

Zend框架中的表单问题

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.

  • 写回答

3条回答 默认 最新

  • dongpeixiong5943 2013-03-23 07:02
    关注

    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.

    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(2条)

报告相同问题?

悬赏问题

  • ¥100 连续两帧图像高速减法
  • ¥15 组策略中的计算机配置策略无法下发
  • ¥15 如何绘制动力学系统的相图
  • ¥15 对接wps接口实现获取元数据
  • ¥20 给自己本科IT专业毕业的妹m找个实习工作
  • ¥15 用友U8:向一个无法连接的网络尝试了一个套接字操作,如何解决?
  • ¥30 我的代码按理说完成了模型的搭建、训练、验证测试等工作(标签-网络|关键词-变化检测)
  • ¥50 mac mini外接显示器 画质字体模糊
  • ¥15 TLS1.2协议通信解密
  • ¥40 图书信息管理系统程序编写