/** * @param sfFormField $field * @param sfValidatorBase $validator * * @return void */ public function __construct(sfFormFieldSchema $field, sfValidatorBase $validator) { parent::__construct('', $field, $validator); }
/** * Get an array of parsers * * @param bool $rebuild * @return array */ protected function _getParserCollection($rebuild = false) { if ($this->_parserCollection === null || $rebuild) { $this->_parserCollection = array(); foreach ($this->getValidators() as $validator) { $parserFactory = new sfJqueryValidationValidatorParserFactory($this->getName(), $this->getField(), $validator); $this->_parserCollection[] = $parserFactory->getParser(); } } return $this->_parserCollection; }
/** * Recursively loop through the form field and validation schema objects * until not schema objects and then get validation rules from them * * @param sfFormFieldSchema $formFieldSchema * @param sfValidatorSchema $validatorSchema * @param boolean $reset * @param boolean $overwrite * * @throws Exception * * @return void */ protected function _recursiveGenerateFieldsAndValidator(sfFormFieldSchema $formFieldSchema, sfValidatorSchema $validatorSchema) { foreach ($formFieldSchema as $name => $field) { if ($field instanceof sfFormFieldSchema) { // check validator schema if (!isset($validatorSchema[$name]) || !$validatorSchema[$name] instanceof sfValidatorSchema) { // field can exist without a validator continue; } $this->_recursiveGenerateFieldsAndValidator($field, $validatorSchema[$name]); // handle pre and post validators connected to validation schema } // check validator if (!isset($validatorSchema[$name]) || !$validatorSchema[$name] instanceof sfValidatorBase) { // field can exist without a validator continue; } $factory = new sfJqueryValidationValidatorParserFactory($field->renderName(), $field, $validatorSchema[$name]); $parser = $factory->getParser(); foreach ($parser->getRules() as $fieldName => $rules) { $this->setFieldRules($fieldName, $rules); } foreach ($parser->getGroups() as $groupName => $fields) { $this->setGroup($groupName, $fields); } $this->setJavascripts(array_merge($this->getJavascripts(), $parser->getJavascripts())); $this->setStylesheets(array_merge($this->getStylesheets(), $parser->getStylesheets())); } // end foreach if ($validatorSchema->getPostValidator()) { // handle main pre post validators $factory = new sfJqueryValidationValidatorParserFactoryPostValidator($formFieldSchema, $validatorSchema->getPostValidator()); $parser = $factory->getParser(); } }
/** * @see parent */ public function __construct($name, sfFormField $field, sfValidatorBase $validator) { $factory = new sfJqueryValidationValidatorParserFactory($name, $field, $validator->getValidator()); $this->setParser($factory->getParser()); parent::__construct($name, $field, $validator); }
/** * @see self::$_parserClassPrefixes * @param array $parserClassPrefixes * @return void */ public static function setParserClassPrefixes(array $parserClassPrefixes) { self::$_parserClassPrefixes = $parserClassPrefixes; }