holografix . schreef:
The form class in APPLICATION_PATH\forms\Login.php
class Form_Login extends Zend_Form
{
public function init() {
$this->setAction('/login')
->setMethod('post')
->setName('formlogin')
->setAttrib('id', 'formlogin');
// Create and configure username element
$username = $this->createElement('text', 'username');
$username->setLabel('User')
->addValidator('alnum')
->addValidator('stringLength', false, array(3, 15))
->setRequired(true)
->setAttrib("size", 20)
->setAttrib('maxLength', 20);
// Create and configure password element
$password = $this->createElement('password', 'password');
$password->setLabel('Password')
->addValidator('StringLength', false, array(3, 15))
->setAttrib("size", 20)
->setAttrib('maxLength', 20)
->setRequired(true);
// Create and configure submit button element
$submit = $this->createElement('submit', 'submit');
$submit->setRequired(false)
->setIgnore(true)
->setLabel('Login');
// Add elements to form
$this->addElement($username)
->addElement($password)
->addElement($submit);
return $this;
}
}
Thanks for the support
holo
2009/4/27 Matthew Weier O'Phinney <[email protected]>
-- holografix . <[email protected]> wrote
(on Monday, 27 April 2009, 04:18 PM +0100):
> problem
> I forgot to tell that this dev box is Win Vista 32
>
> In bootstrap.php:
>
> $module = new Zend_Application_Module_Autoloader(array(
> 'namespace' => '',
> 'basePath' => APPLICATION_PATH . '/forms'
> ));
> Warning: include(C:\wwwroot\devapp\application/forms/forms//
Login.php) [
> function.include]: failed to open stream: No such file or directory
>
> I change 'basePath' from APPLICATION_PATH . '/forms' to
APPLICATION_PATH
>
> $module = new Zend_Application_Module_Autoloader(array(
> 'namespace' => '',
> 'basePath' => APPLICATION_PATH
> ));
> Renamed APPLICATION_PATH\forms\Form_Login.php to Login.php and
removed the
> include of this file in controller action.
My bad -- I jumped the gun. Yes, basePath => APPLICATION_PATH is what I
meant to write.
> The file is loaded but the output is the same:
>
> <form action="/login"
> method="post"
> id="formlogin"
> name="loginform">
>
> <fieldset>
> <legend>Login</legend>
>
> <form id="username"></form>
> <form id="password"></form>
> <form id="submit"></form>
> </fieldset>
> </form>
Can you provide the form class itself so I can take a look at it? Right
now, I have no idea what's wrong, nor how it could be generated.
Thanks!
> Cheers
> holo
> 2009/4/27 Matthew Weier O'Phinney <[email protected]>
>
> -- 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/
>
>
--
Matthew Weier O'Phinney
Project Lead | [email protected]
Zend Framework | http://framework.zend.com/