ZF-9118: Sample code incorrect in authentication tutorial
Description
Page: http://framework.zend.com/manual/en/…
In the script for authController, lines 8-10 are currently:
08 $loginForm = new Default_Form_Auth_Login($_POST); 09 10 if ($loginForm->isValid()) {
It should probably say
08 $loginForm = new Default_Form_Auth_Login(); 09 10 if ($loginForm->isValid($_POST)) {
Also, the auth/login.phtml refers to $this->form when it should probably refer to $this->loginForm
Comments
Posted by fisharebest (fisharebest) on 2010-02-08T16:08:21.000+0000
Also, line 23 uses $auth, which is not defined anywhere.
Also, (possibly not a bug, just me being a bumbling novice!), $this->_getParam('db') returns null, rather than a DbAdapter object.
I'm attaching this controller/action to the quickstart tutorial code (which seems to use the db adapter without doing any initialisation).
Posted by PVWebGuy (cewolfe) on 2010-02-17T10:27:17.000+0000
Has anyone figured out the issue with the sample code? If so, please post!
Posted by Menencia (menencia) on 2010-03-02T23:29:34.000+0000
Well, I'm new too and I try to fix the source code as next:
Don't forget to initialize the session with a Zend_Session::start(); Also, in the auth/login.phtml, correct $this->form into $this->loginForm
Works here. Hope it helps you ;)
Posted by Thomas Weidner (thomas) on 2010-03-15T11:23:08.000+0000
Assigned correct component
Posted by Remy Damour (remy215) on 2010-04-29T10:03:39.000+0000
I personally added a submit-page check so that 'Value is required and can't be empty' does not get displayed when we first land on the page.
I replaced:
Posted by Remy Damour (remy215) on 2010-04-29T11:35:47.000+0000
as fisharebest said, $auth is not defined!
I had to replace:
Posted by Remy Damour (remy215) on 2010-04-29T12:07:21.000+0000
on line 27, $this->redirect('/') generated an error (unknown method 'redirect')
I replaced:
Posted by Ramon Henrique Ornelas (ramon) on 2011-04-23T22:12:39.000+0000
Fix in trunk r23868 and merged to branch release 1.11 r23869 - thanks.