/** * @param CM_FormAction_Abstract $action * @param array $data * @param CM_Frontend_ViewResponse $scopeComponent * @return CM_Http_Response_View_Form */ public function getResponseFormAction(CM_FormAction_Abstract $action, array $data = null, CM_Frontend_ViewResponse $scopeComponent = null) { $site = CM_Site_Abstract::factory(); $request = $this->createRequestFormAction($action, $data, $scopeComponent); $response = CM_Http_Response_View_Form::createFromRequest($request, $site, $this->getServiceManager()); $response->process(); return $response; }
/** * @param array $data * @param string $actionName * @param CM_Http_Response_View_Form $response * @return mixed */ public function process(array $data, $actionName, CM_Http_Response_View_Form $response) { $action = $this->getAction($actionName); $formData = array(); foreach ($action->getFieldList() as $fieldName => $required) { $field = $this->getField($fieldName); $isEmpty = true; if (array_key_exists($fieldName, $data)) { $fieldValue = $field->filterInput($data[$fieldName]); if (!$field->isEmpty($fieldValue)) { $isEmpty = false; $environment = $response->getRender()->getEnvironment(); try { $formData[$fieldName] = $field->validate($environment, $fieldValue); } catch (CM_Exception_FormFieldValidation $e) { $response->addError($e->getMessagePublic($response->getRender()), $fieldName); } } } if ($isEmpty) { if ($required) { $response->addError($response->getRender()->getTranslation('Required'), $fieldName); } else { $formData[$fieldName] = null; } } } if (!$response->hasErrors()) { $action->checkData($formData, $response, $this); } if ($response->hasErrors()) { return null; } return $action->process($formData, $response, $this); }
protected function _process(CM_Params $params, CM_Http_Response_View_Form $response, CM_Form_Abstract $form) { //$response->reloadComponent(); $response->addMessage(nl2br($this->_printVar($params->getParamsDecoded()))); }