Monday, October 4, 2010

Assemble Route URL inside Zend_Form

If you want to assemble a route URL inside a Zend_Form (or any other object where you don't have access to the URL View Helper), get an instance of the router and call the assemble method like this:

class Abispulsa_Deposit_Claim extends Zend_Form {

  public function init() {
    $router = Zend_Controller_Front::getInstance()->getRouter();
    $url = $router->assemble(array('module' => 'deposit', 'controller' => 'index', 'action' => 'claim'));
    $this->setAction($url)->setMethod(self::METHOD_POST);
    ...

    Hope this is useful.

No comments:

Post a Comment