/**
  * Generates generic rules for a time (expecting a single field like a input
  * text)
  *
  * @return  void
  */
 protected function _generateGenericWidgetRules()
 {
     parent::_generateRules();
     if ($this->getValidator()->getOption('time_format')) {
         $timeFormatError = $this->getValidator()->getOption('time_format_error') ? $this->getValidator()->getOption('time_format_error') : $this->getValidator()->getOption('time_format');
         $this->addRule('regex', new sfJqueryValidationValidatorRule($this->getValidator()->getOption('time_format'), $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('bad_format'), array('%value%' => sfJqueryValidationParsersfValidatorBase::PRINT_JQUERY_VALUE, '%time_format%' => $timeFormatError)), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
     }
 }
 /**
  * @see   parent
  */
 protected function _generateRules()
 {
     parent::_generateRules();
     $ruleSchema = new sfJqueryValidationValidatorRuleSchema($this->getName(), $this->getField(), $this->getValidator()->getValidators());
     if ($this->getValidator()->getMessage('invalid')) {
         $ruleSchema->setMessage($this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('invalid'), array('%value%' => sfJqueryValidationParsersfValidatorBase::PRINT_JQUERY_VALUE)), sfJqueryValidationValidatorRule::STR_RAW);
     }
     $this->addRule('and', $ruleSchema);
 }
 /**
  * @see   parent
  */
 protected function _generateRules()
 {
     parent::_generateRules();
     if ($this->getValidator()->hasOption('max_length')) {
         $this->addRule('maxlength', new sfJqueryValidationValidatorRule($this->getValidator()->getOption('max_length'), $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('max_length'), array('%value%' => sfJqueryValidationParsersfValidatorBase::PRINT_JQUERY_VALUE, '%max_length%' => 'ruleParams')), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
     }
     if ($this->getValidator()->hasOption('min_length')) {
         $this->addRule('minlength', new sfJqueryValidationValidatorRule($this->getValidator()->getOption('min_length'), $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('min_length'), array('%value%' => sfJqueryValidationParsersfValidatorBase::PRINT_JQUERY_VALUE, '%min_length%' => 'ruleParams')), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
     }
 }
 /**
  * @see   parent
  */
 protected function _generateRules()
 {
     parent::_generateRules();
     // match int by regular experession
     $this->addRule('number', new sfJqueryValidationValidatorRule('true', $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('invalid'), array('%value%' => sfJqueryValidationParsersfValidatorBase::PRINT_JQUERY_VALUE)), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
     if ($this->getValidator()->hasOption('max')) {
         $this->addRule('max', new sfJqueryValidationValidatorRule($this->getValidator()->getOption('max'), $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('max'), array('%value%' => sfJqueryValidationParsersfValidatorBase::PRINT_JQUERY_VALUE, '%max%' => 'ruleParams')), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
     }
     if ($this->getValidator()->hasOption('min')) {
         $this->addRule('min', new sfJqueryValidationValidatorRule($this->getValidator()->getOption('min'), $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('min'), array('%value%' => sfJqueryValidationParsersfValidatorBase::PRINT_JQUERY_VALUE, '%min%' => 'ruleParams')), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
     }
 }
 /**
  * Sets the validation rules, if its a multiple change name to have the []
  * suffix
  *
  * @see     parent
  * @return  void
  */
 protected function _generateRules()
 {
     $widget = $this->getField()->getWidget();
     // set the name for a multiple
     if ($widget->getOption('multiple')) {
         $this->setName($this->getName() . '[]');
     }
     parent::_generateRules();
     if ($this->getValidator()->hasOption('max')) {
         $this->addRule('maxlength', new sfJqueryValidationValidatorRule($this->getValidator()->getOption('max'), $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('max'), array('%max%' => 'ruleParams', '%count%' => 'this.getLength(jQuery(element).val(), element)')), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
     }
     if ($this->getValidator()->hasOption('min')) {
         $this->addRule('minlength', new sfJqueryValidationValidatorRule($this->getValidator()->getOption('min'), $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('min'), array('%min%' => 'ruleParams', '%count%' => 'this.getLength(jQuery(element).val(), element)')), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
     }
 }
 /**
  * @see   parent
  */
 protected function _generateRules()
 {
     parent::_generateRules();
     $choices = array_merge($this->getValidator()->getOption('true_values'), $this->getValidator()->getOption('false_values'));
     $this->addRule('choice', new sfJqueryValidationValidatorRule($this->buildChoices($choices), $this->generateMessageJsFunctionReplace($this->getValidator()->getMessage('invalid'), array('%value%' => sfJqueryValidationParsersfValidatorBase::PRINT_JQUERY_VALUE)), sfJqueryValidationValidatorRule::STR_RAW, sfJqueryValidationValidatorRule::STR_RAW));
 }
 /**
  * Generates generic rules for a date (expecting a single field like a input
  * text)
  *
  * @return  void
  */
 protected function _generateGenericWidgetRules()
 {
     parent::_generateRules();
     $this->addRule('date', new sfJqueryValidationValidatorRule('true', $this->getValidator()->getMessage('invalid')));
     // max date
     if ($this->getValidator()->getOption('max')) {
         $max = $this->getValidator()->getOption('max');
         if (is_numeric($max)) {
             $errorMessage = strtr($this->getValidator()->getMessage('max'), array('%max%' => date($this->getValidator()->getOption('date_format_range_error'), $max)));
             $this->addRule('maxDate', new sfJqueryValidationValidatorRule($max, $errorMessage));
         } else {
             $dateMax = new DateTime($max);
             $errorMessage = strtr($this->getValidator()->getMessage('max'), array('%max%' => $dateMax->format($this->getValidator()->getOption('date_format_range_error'))));
             $this->addRule('maxDate', new sfJqueryValidationValidatorRule($dateMax->format('U'), $errorMessage));
         }
     }
     // min date
     if ($this->getValidator()->getOption('min')) {
         $min = $this->getValidator()->getOption('min');
         if (is_numeric($min)) {
             $errorMessage = strtr($this->getValidator()->getMessage('min'), array('%min%' => date($this->getValidator()->getOption('date_format_range_error'), $min)));
             $this->addRule('minDate', new sfJqueryValidationValidatorRule($min, $errorMessage));
         } else {
             $dateMin = new DateTime($min);
             $errorMessage = strtr($this->getValidator()->getMessage('min'), array('%min%' => $dateMin->format($this->getValidator()->getOption('date_format_range_error'))));
             $this->addRule('maxDate', new sfJqueryValidationValidatorRule($dateMin->format('U'), $errorMessage));
         }
     }
 }
 /**
  * @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);
 }