Welcome, Guest. Register Now!
   
Mark Forums Read Mark Forums Read Mark Forums Read


Reply
 
LinkBack Thread Tools Display Modes
  #1 (permalink)  
Old 03-02-2008, 01:07 PM
Junior Member
 
Join Date: Mar 2008
Posts: 1
Default forward to another action breaks current action

I created a BaseAction class which extends Zend_Controller_Action. All my actions extend from this BaseAction.
In this BaseAction class I have a processForm method for validating the $_POST values based on a Zend_Validate chain. This method can be called from all the actions that need to process form data. I want this method to return the $_POST values if the form validates and forward to another action if form doesn't validate. See code below.

BaseAction.php
PHP Code:
abstract class BaseAction extends Zend_Controller_Action {
    ...
    protected function 
processForm($action, array $rules$filters = array()) {
        
// create a Zend validate chain
        
...
        if (
$chain->isValid()) {
            
// return the values
        
} else {
            
// forward to the $action
            
$this->_forward($action);
        }
    }
    ...

IndexController.php
PHP Code:
class IndexController extends Web_Util_Action {
    ...
    public function 
processAction() {
        
// return the form fields it the form validates
        // forward to the index action in this controller if the form doesn't validate
        
$fields $this->processForm('index'$rules);
        
// continue processing
        
...
    }
    ...

In this case, when processAction is called, it will validate the $_POST values. In case the form validates, it returns the values. But if the form doesn't validate, it forwards to the index action, BUT continues to processing the rest of action.
What I want/need is a way to forward to another action and stop the current action.
I know I could return false from processForm if the form doesn't validate and put the processForm statement in the processAction in an if-statement that would call break on false, but this to much code in the action.
Does anybody know how to forward instantly to another action and stop going futher in the current action?
Digg this Post!Add Post to del.icio.usBookmark Post in TechnoratiFurl this Post!
Reply With Quote
Reply


Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are On



All times are GMT. The time now is 11:24 PM.