Search code examples
phphtmlzend-frameworkautoloader

Zend autoloader


I am trying to autoload the forms found in my project under application/forms/*.php ( in this case, LoginForm.php ).

How do I configure Zends autoloader to load this form automatically? As I don't want to use ugly namespaces I am enabling the fallback in my bootstrap. I haven't got anything related to forms configured in my application.ini

thanks!


Solution

  • The default autoloader will load this for you. Make sure that you have checked the following:-

    1. Your file is application/forms/Loginform.php
    2. The file contains something like this:-

      class Application_Form_Loginform extends Zend_Form
      {
         //Take special note of the capitalisation - it is important
         // Also note it is Form NOT Forms
          public function init()
          {
              //Your code here
          }
      }
      
    3. Call your class like this:-

      $form = new Application_Form_Loginform();
      

    Take extra care over letter case, it is important that you get it exactly right or the autoloader will not find you class and will complain.