Zend Forms Module Include Paths

后端 未结 3 1535
暗喜
暗喜 2021-01-07 06:35

I\'m using Zend 1.8.4 and setting up a simple form test. My form class is located in \'./application/forms/SectorSearch.php\' and the class name is



        
相关标签:
3条回答
  • 2021-01-07 07:05

    Make sure the case matches exactly. The folder has to be named Forms unless you specified different directory for Form classes and make sure SectorSearch is not sEcTorSEarcH.php or something

    0 讨论(0)
  • 2021-01-07 07:09

    Zend Framework interprets underscores in Class names as folders. If you are manually adding the application/forms folder to the include path, then you should name your class FormSectorSearch (and the filename FormSectorSearch.php) instead of Form_SectorSearch. Otherwise you would only add the application folder to the include path and then named the folder Form instead of forms.

    0 讨论(0)
  • 2021-01-07 07:13

    I added the following to my Bootstrap.php file

    protected function _initAutoload()
        {
            $autoloader = new Zend_Loader_Autoloader_Resource(array(
                'namespace' => '',
                'basePath' => APPLICATION_PATH,
                'resourceTypes' => array(
                    'form' => array(
                        'path' => 'forms',
                        'namespace' => 'Form',
                    ),
                    'model' => array(
                        'path' => 'models',
                        'namespace' => 'Model',
                    ),
                )
            ));
            return $autoloader;
        }
    

    and now it works, no errors anymore.. damn i'm glad it works, i was almost going mad.. :)

    0 讨论(0)
提交回复
热议问题