public function execute($filterChain) { $context = $this->context; if ($this->isFirstCall() && $context->getRequest()->getMethod() == sfRequest::POST) { $actionInstance = $this->context->getActionStack()->getLastEntry()->getActionInstance(); $formcfg = self::getFormConfig($context); if ($formcfg === null) { $edit = $actionInstance->getRequestParameter('edit'); $apikey = $context->getRequest()->hasParameter('af_apikey'); if (!is_array($edit) || !$apikey) { // Normal AJAX POST requests and plain forms don't have // validators from the XML config. $validators = array(); $formcfg = array(); } else { self::renderErrors(array(), 'The form is outdated. Please, refresh it.'); } } else { $validators = $formcfg['validators']; $fileTypes = $formcfg['fileTypes']; } if (ArrayUtil::get($formcfg, 'wizard', false)) { afWizard::checkStepOrRenderError(); } $errors = array(); $errorMessage = null; $requestParameters = sfToolkit13::arrayDeepMerge($context->getRequest()->getParameterHolder()->getAll(), $context->getRequest()->getFiles()); foreach ($validators as $field => $fieldValidators) { $tmp_field = $field; if ($fileTypes[$field] == 'combo') { $tmp_field = substr($field, 0, -1) . "_value]"; } foreach ($fieldValidators as $class => $args) { $params = ArrayUtil::get($args, 'params', array()); $validator = afValidatorFactory::createValidator($class, $params); $value = afValidatorFactory::prepareValue($tmp_field, $validator, $requestParameters); try { $validator->clean($value); } catch (sfValidatorError $e) { $errors[] = array($tmp_field, $e->getMessage()); } } } if (!empty($errors)) { self::renderErrors($errors, $errorMessage); } if (ArrayUtil::get($formcfg, 'wizard', false)) { $this->updateWizardState(); } self::removeIterationNumber($this->context->getRequest()->getParameterHolder()); } return $filterChain->execute(); }