Esempio n. 1
0
 public function notifyRule(Rule $rule)
 {
     if (is_string($rule->operation) && strcasecmp($rule->operation, ':range') === 0 && !$rule->isNegative && $this->control->type !== 'text') {
         list($this->control->min, $this->control->max) = $rule->arg;
         // for HTML 5
     }
     parent::notifyRule($rule);
 }
Esempio n. 2
0
 public function notifyRule(Rule $rule)
 {
     if (is_string($rule->operation) && strcasecmp($rule->operation, ':length') === 0 && !$rule->isNegative) {
         $this->control->maxlength = is_array($rule->arg) ? $rule->arg[1] : $rule->arg;
     } elseif (is_string($rule->operation) && strcasecmp($rule->operation, ':maxLength') === 0 && !$rule->isNegative) {
         $this->control->maxlength = $rule->arg;
     }
     parent::notifyRule($rule);
 }
Esempio n. 3
0
 /**
  * Generates control's HTML element.
  * @return Nette\Web\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     foreach ($this->getRules() as $rule) {
         if ($rule->isNegative || $rule->type !== Rule::VALIDATOR) {
         } elseif ($rule->operation === Form::RANGE && $control->type !== 'text') {
             list($control->min, $control->max) = $rule->arg;
         } elseif ($rule->operation === Form::PATTERN) {
             $control->pattern = $rule->arg;
         }
     }
     if ($control->type !== 'password') {
         $control->value = $this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value;
     }
     return $control;
 }
Esempio n. 4
0
 /**
  * Generates control's HTML element.
  * @return Nette\Web\Html
  */
 public function getControl()
 {
     $control = parent::getControl();
     $control->setText($this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value);
     return $control;
 }
Esempio n. 5
0
 /**
  * Rangle validator: is a control's value number in specified range?
  * @param  TextBase
  * @param  array  min and max value pair
  * @return bool
  */
 public static function validateRange(TextBase $control, $range)
 {
     return ($range[0] === NULL || $control->getValue() >= $range[0]) && ($range[1] === NULL || $control->getValue() <= $range[1]);
 }