コード例 #1
0
ファイル: TextInput.php プロジェクト: jakubkulhan/nette
 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);
 }
コード例 #2
0
ファイル: TextInput.php プロジェクト: nella/ActiveMapper
 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);
 }
コード例 #3
0
ファイル: TextInput.php プロジェクト: JanTvrdik/nette
 /**
  * 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;
 }
コード例 #4
0
ファイル: TextArea.php プロジェクト: JPalounek/IconStore
 /**
  * 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;
 }
コード例 #5
0
ファイル: TextBase.php プロジェクト: nella/ActiveMapper
 /**
  * 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]);
 }