2009年4月13日星期一

Re: [fw-mvc] How to Zend_View->url() for Zend_From->setAction()

You could override the setAction() method and pull the view object from there.

class My_Form extends Zend_Form
{
    public function setAction($params)
    {
        $view = $this->getView();
        $url = $view->url($params, 'multilanguage');
        parent::setAction($url);
    }
}

// elsewhere
$form = new My_Form(array(
    'action' => array(
            'controller' => 'foo',
            'action' => 'bar',
            'lang' => 'en'),
));

In a config, it might look like this:

[Forms]
...
foo.action.controller = foo
foo.action.action = bar
foo.action.lang = en
...


$conf = new Zend_Config_Ini('../config.ini', 'Forms');
$form = new My_Form($conf->foo);

   -- Mon


On Tue, Apr 14, 2009 at 2:16 AM, K.L. <coviex@gmail.com> wrote:
Hi!

Is there any build-in functionality to use Zend_View->url() notation
for setting forms' actions? Most interesting if it can be done with
forms build from Zend_Config.
I need it to match "multilanguage" route.

Regards,
Kostya

没有评论: