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?

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()

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...

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

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');
        ...
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.