_prefill = $options['prefill']; unset($options['prefill']); } */ $this->request = Front::getInstance()->getRequest(); // $this->handleRequest(); foreach ($this->elements() as $key => $values) { $this->addElement($values[0], $key, $values[1]); // do it better! } // Should be replaced with button check: $this->addElement('hidden', '__submitted'); $this->setDefaults(array('__submitted' => 'true')); parent::__construct($options); if ($this->getAttrib('action') === null) { $this->setAction($this->request->getRequestUri()); } if ($this->getAttrib('method') === null) { $this->setMethod('post'); } if ($this->hasBeenSubmitted()) { $this->handleRequest(); } } public function redirectNow($url) { ZfActionHelper::getStaticHelper('redirector') ->gotoUrlAndExit($url); } public function handleRequest() { if ($this->isValid($this->request->getPost())) { $this->onSuccess(); } else { $this->onFailure(); } } public function onSuccess() { } public function onFailure() { } public function hasBeenSubmitted() { return $this->request->getPost('__submitted', 'false') === 'true'; } public function elements() { return array(); } }