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条)

报告相同问题?

悬赏问题

  • ¥15 identifier of an instance of 类 was altered from xx to xx错误
  • ¥100 反编译微信小游戏求指导
  • ¥15 docker模式webrtc-streamer 无法播放公网rtsp
  • ¥15 学不会递归,理解不了汉诺塔参数变化
  • ¥30 软件自定义无线电该怎样使用
  • ¥15 R语言mediation包做中介分析,直接效应和间接效应都很小,为什么?
  • ¥15 Jenkins+k8s部署slave节点offline
  • ¥15 如何实现从tello无人机上获取实时传输的视频流,然后将获取的视频通过yolov5进行检测
  • ¥15 WPF使用Canvas绘制矢量图问题
  • ¥15 用三极管设计一个单管共射放大电路