English 中文(简体)
2.0P 2.0
原标题:Error with Form helper in CakePHP 2.0

我先从CakePHP 2.0开始,可以 past一 past。 这是我的法典:

<<>AppController>:

class AppController extends Controller
{
    function beforeFilter()
    {
        $this->Auth->userModel =  User ;
        $this->Auth->fields = array( username  =>  email ,  password  =>  password ); 
        $this->Auth->loginAction = array( controller  =>  users ,  action  =>  login );
        $this->Auth->loginRedirect = array( controller  =>  hotels ,  action  =>  dashboard );
    }
}

UsersController:

class UsersController extends AppController
{
    var $name =  Users ;
    var $helpers = array( Html , Form );
    var $components = array( Auth , Session );

    function beforeFilter()
    {
        $this->Auth->allow("logout");
        parent::beforeFilter();
    }

    function logout()
    {
        $this->redirect($this->Auth->logout());
    }

    function login()
    {
        if ($this->Auth->login())
        {
            $this->redirect($this->Auth->redirect());
        } else
        {
            $this->Session->setFlash(__( Invalid username or password, try again ));
        }
    }
}

<>strong>login.ctp:

 echo $this->Form->create(); // User , array( action  =>  login ));
 echo $form->Form->input( email );
 echo $form->Form->input( password );
 echo $form->Form->end( Login );

错误是:

 Notice (8): Undefined variable: form [APPViewUserslogin.ctp, line 13]
 Notice (8): Trying to get property of non-object [APPViewUserslogin.ctp, line 13]
 Fatal error: Call to a member function input() on a non-object in E:proyectoswebswtappViewUserslogin.ctp on line 13

Any ideas? Thanks in advance!

最佳回答

这些

echo $form->Form->input( email );
echo $form->Form->input( password );
echo $form->Form->end( Login );

应当

echo $this->Form->input( email );
echo $this->Form->input( password );
echo $this->Form->end( Login );
问题回答

暂无回答




相关问题
ajax login using httpRequest?

I am trying to develop my login script to give feedback to the user if the login is valid or not. Basically if it isn t correct a div box will show saying its wrong, if its correct it will show its ...

Remotely authenticating client Windows user on demand

Suppose I am writing a server for a particular network protocol. If I know that the client is running on a Windows machine, is it possible for my server to authenticate the Windows user that owns the ...

Role/Permission based forms authorizing/authentication?

While looking into forms authorizing/authentication, I found that it is possible to do role based authorizing by adding an array of roles to a FormsAuthenticationTicket. That way I can write User....

热门标签