-- holografix . <[email protected]> wrote
(on Monday, 27 April 2009, 02:34 PM +0100):
> I have an application developed with ZF 1.7 and it works fine up to ZF 1.7.8.
> After update developpment box to ZF to latest trunk version,
> starting to get notices about Zend_Loader::registerAutoload(), saying it's
> deprecated and will be removed in 2.0.0.
> This application follows ZF directory structure and it registers a front
> controller plugin where resources are initialized.
> 
> New code in bootstrap.php:
>  
> require_once 'Zend/Loader/Autoloader.php';
> 
> $loader = Zend_Loader_Autoloader::getInstance()->setFallbackAutoloader(true);
> $loader->registerNamespace('ZendExt_');
> 
> $front = Zend_Controller_Front::getInstance();
> $front->registerPlugin(new ZendExt_Plugin_Initialize(APPLICATION_ENV));
> 
> Resources are initialized but have some problems with loading a form.
> 
> When opening the application, if one is not logged in, it redirects to index/
> login (Form_Login.php)
> http://application => http://application/login
> 
> Forms are in a dir called forms under application dir.
> In login action I have this code
> 
> public function loginAction()
> {
>     include APPLICATION_PATH . "/forms/Form_Login.php";
> 
>     $loginForm = new Form_Login();
>    
>     ... validation and authentication
> }   
> 
> The output is wrong
> 
> <form action="/login" method="post" id="formlogin" name="formlogin">
> <fieldset>
>     <legend>Login</legend>   
>     <form id="username"></form>   
>     <form id="password"></form>   
>     <form id="submit"></form>
> </fieldset>
> </form>
> 
> 
> With Zend_Loader there are no problems.
> How can I fix the problem ?

Use a module autoloader:

    $module = new Zend_Application_Module_Autoloader(array(
        'namespace' => '',
        'basePath'  => APPLICATION_PATH . '/forms',
    ));

Then make sure your form is in the file:

    APPLICATION_PATH/
        forms/
            Login.php

and contains the clas 'Form_Login'.

You can do that anywhere -- your bootstrapping code is probably the best
place, however. Once you have, you will not need to do an
include/include_once to get your form -- just 'new Form_Login()'.

-- 
Matthew Weier O'Phinney
Project Lead            | [email protected]
Zend Framework          | http://framework.zend.com/

Reply via email to