Nette\Forms\Controls\TextBase::getControl PHP Method

getControl() public method

public getControl ( )
    public function getControl()
    {
        $el = parent::getControl();
        if ($this->emptyValue !== '') {
            $el->attrs['data-nette-empty-value'] = Strings::trim($this->translate($this->emptyValue));
        }
        if (isset($el->placeholder)) {
            $el->placeholder = $this->translate($el->placeholder);
        }
        return $el;
    }

Usage Example

Exemplo n.º 1
0
 /**
  * Generates control's HTML element.
  * @return Nette\Utils\Html
  */
 public function getControl()
 {
     $input = parent::getControl();
     foreach ($this->getRules() as $rule) {
         if ($rule->isNegative || $rule->branch) {
         } elseif (in_array($rule->validator, [Form::MIN, Form::MAX, Form::RANGE], TRUE) && in_array($input->type, ['number', 'range', 'datetime-local', 'datetime', 'date', 'month', 'week', 'time'], TRUE)) {
             if ($rule->validator === Form::MIN) {
                 $range = [$rule->arg, NULL];
             } elseif ($rule->validator === Form::MAX) {
                 $range = [NULL, $rule->arg];
             } else {
                 $range = $rule->arg;
             }
             if (isset($range[0]) && is_scalar($range[0])) {
                 $input->min = isset($input->min) ? max($input->min, $range[0]) : $range[0];
             }
             if (isset($range[1]) && is_scalar($range[1])) {
                 $input->max = isset($input->max) ? min($input->max, $range[1]) : $range[1];
             }
         } elseif ($rule->validator === Form::PATTERN && is_scalar($rule->arg) && in_array($input->type, ['text', 'search', 'tel', 'url', 'email', 'password'], TRUE)) {
             $input->pattern = $rule->arg;
         }
     }
     if ($input->type !== 'password' && ($this->rawValue !== '' || $this->emptyValue !== '')) {
         $input->value = $this->rawValue === '' ? $this->translate($this->emptyValue) : $this->rawValue;
     }
     return $input;
 }
All Usage Examples Of Nette\Forms\Controls\TextBase::getControl