/** * Method description * * More detailed method description * @param void * @return void */ function preRender() { if (isset($this->valuechecker)) { $this->valuechecker->addWidgetId($this->getId()); $event = new WidgetEvent("have_valuechecker", $this->getId()); $event->setParams(array('id' => $this->valuechecker->getId())); Controller::getInstance()->getDispatcher()->notify($event); } parent::preRender(); if (POSTErrors::hasErrors()) { $this->restorePOST(); } }
/** * Handles POST data while AJAX request. * It works like {Controller::handlePOST} and signaatures will be checked unless * form is on the current page and <code>no_check</code> attribute is not specified. * * Typical use-case of this function is posting form with javascript with * <code>$(form).serialize()</code> method or <code>ajaxSubmit</code> from * jquert.form plugin. * * Instead of redirects, like in <code>Controller::handlePOST()</code> * method, <code>exit()</code> calls will be used. * * Another difference is that no "save form values and show error boxes" sequence * is used. If some checker of validator error are present, <code>exit()</code> * will terminate futher form processing. * * Additionally, unlike <code>Controller::handlePOST</code>, handler methods could specify * <code>responce_string</code> to return status of form processing. It will be echo'ed at once. * * @param null * @return null */ protected function handlePOST() { $this->trigger("BeforeHandlePOST", $this); if ($this->post->isEmpty()) { Header::redirect(requestURI(true), Header::SEE_OTHER); } $formid = null; WidgetLoader::load("WForm"); list($formid) = explode(":", $this->post->{WForm::signature_name}); if (!empty($formid) && !in_array($formid, $this->no_check_forms)) { $this->trigger("BeforeCheckSignature", $this); if (!$this->checkSignature($this->post->{WForm::signature_name})) { exit("Error while checking POST data 1"); } POSTErrors::flushErrors(); $this->trigger("BeforeCheckByRules", array(&$this->post, $this->post->{WForm::signature_name})); POSTChecker::checkByRules($this->post->{WForm::signature_name}, $this->checker_rules, $this->checker_messages); POSTChecker::checkFiles($this->post->{WForm::signature_name}, $this->file_rules, $this->checker_messages); if (POSTErrors::hasErrors()) { //Header::redirect(requestURI(true), Header::SEE_OTHER); exit("Error while checking POST data 2"); } $this->trigger("BeforeCallHandlers", array($this, &$formid)); try { DataUpdaterPool::callCheckers($formid); } catch (CheckerException $e) { exit("Error " . $e->getMessage() . " in widget " . $e->getWidgetName); } DataUpdaterPool::callHandlers($formid); DataUpdaterPool::callFinalize($formid); } else { try { DataUpdaterPool::callCheckers($formid); } catch (CheckerException $e) { exit("Error " . $e->getMessage() . " in widget " . $e->getWidgetName); } DataUpdaterPool::callHandlers($formid); DataUpdaterPool::callFinalize($formid); } $this->trigger("AfterHandlePOST", $this); if (isset($this->response_string)) { $this->trigger("AfterHeadBodyTailResponce", array($this, &$this->response_string)); echo $this->response_string; } }