Forms have access to a view object, which it pulls automatically from the ViewRenderer action helper. class MyForm extends Zend_Form { public function init() { $action = $this->getView()->url(/* ... */); $this->setAction($action); /* ... */ } }
-- Hector On Wed, Oct 21, 2009 at 6:47 AM, Саша Стаменковић <umpir...@gmail.com>wrote: > Why I want to do this in the form is, I want to set url on one place. Form > will be rendered in many views, I don't want each of them set separate url, > want to do it in one place, in the form init. > > Regards, > Saša Stamenković > > > > On Wed, Oct 21, 2009 at 3:22 PM, Kyle Spraggs <the...@spiffyjr.me> wrote: > >> >> >> >> umpirsky wrote: >> > >> > Hi. >> > >> > I wonder, if you want to use url helper for all urls in your app, you >> can >> > access it from view with $this->url(). from controller with >> > $this->wiew->url()... >> > >> > But when you want for example to use it to set action of a form in form >> > init() method, do you access it through front controller or bootstrap or >> > you set action explicitly in the view script? >> > What is the right way to go? >> > >> > Regards, >> > Sasa Stamenkovic. >> > >> >> You can do that easily using the form view helper and the URL of the >> calling >> page so doing so from the init() method isn't required. For example, >> >> indexAction() >> { >> $this->view->form = new Default_Form_MyForm(); >> } >> >> >> index.phtml >> <?=$this->form->setAction($this->url());?> >> >> You could probably do it in the form using the helper broker but I've >> never >> had a need to do so. >> -- >> View this message in context: >> http://www.nabble.com/url-helper-available-all-over-your-app-tp25992262p25992433.html >> Sent from the Zend Framework mailing list archive at Nabble.com. >> >> >