0

I have a login form 'Application_Form_Login' that I call in 'Application_View_Helper_Auth', so that the signin form appears on all pages. If I login from 'index/index', everything is ok, but it doesn't work correctly if I login from 'index/otheraction' or 'othercontroller/index'. The form code starts as follows:

class Application_Form_Login extends Zend_Form
{
    public function  __construct($options = null)
    {
        parent::__construct($options);
        $this->setName('login');
        $this->setMethod('post');
        $this->setAction("/auth/index");
        ...

Please help, where should I change something to make it work?

2
Contributors
5
Replies
18
Views
4 Years
Discussion Span
Last Post by eburlea
0

This is the way I do MVC in instances like this. I post the form to self (eg: the curent URL) validate the form on the fly and check for credentials if all is well redirect to the auth pages.

In other words above the line :

$this->setAction("/auth/index");

you need to get the current url and pass it to the setAction()

0

In my code it is exactly the same and that's why I post here, maybe there is other thing to do when calling the form from a view helper...

0

The current url is not being declared nor do you have a redirection as I said in the code you have posted.

0

After many hours of googling, I have found a solution that works on: http://www.hardcode.nl/archives_132/article_564-get-baseurl-inside-a-zend-form-descendant-class.htm and implemented it as follows:

class Application_Form_Login extends Zend_Form
{
    public function  __construct($options = null)
    {
        parent::__construct($options);
        $this->setName('login');
        $this->setMethod('post');
        $view = Zend_Layout::getMvcInstance()->getView();
        $this->setAction($view->baseUrl() . '/auth/index');
        ...
This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.