Namespaces

  • Nette
    • Application
      • Diagnostics
      • Responses
      • Routers
      • UI
    • Caching
      • Storages
    • ComponentModel
    • Config
      • Adapters
      • Extensions
    • Database
      • Diagnostics
      • Drivers
      • Reflection
      • Table
    • DI
      • Diagnostics
    • Diagnostics
    • Forms
      • Controls
      • Rendering
    • Http
    • Iterators
    • Latte
      • Macros
    • Loaders
    • Localization
    • Mail
    • Reflection
    • Security
      • Diagnostics
    • Templating
    • Utils
      • PhpGenerator
  • NetteModule
  • none

Classes

  • BaseControl
  • Button
  • Checkbox
  • HiddenField
  • ImageButton
  • MultiSelectBox
  • RadioList
  • SelectBox
  • SubmitButton
  • TextArea
  • TextBase
  • TextInput
  • UploadControl
  • Overview
  • Namespace
  • Class
  • Tree
  • Deprecated
  • Other releases
  • Nette homepage
 1: <?php
 2: 
 3: /**
 4:  * This file is part of the Nette Framework (https://nette.org)
 5:  * Copyright (c) 2004 David Grudl (http://davidgrudl.com)
 6:  */
 7: 
 8: namespace Nette\Forms\Controls;
 9: 
10: use Nette;
11: 
12: 
13: /**
14:  * Single line text input control.
15:  *
16:  * @author     David Grudl
17:  * @property-write $type
18:  */
19: class TextInput extends TextBase
20: {
21: 
22:     /**
23:      * @param  string  label
24:      * @param  int  width of the control
25:      * @param  int  maximum number of characters the user may enter
26:      */
27:     public function __construct($label = NULL, $cols = NULL, $maxLength = NULL)
28:     {
29:         parent::__construct($label);
30:         $this->control->type = 'text';
31:         $this->control->size = $cols;
32:         $this->control->maxlength = $maxLength;
33:     }
34: 
35: 
36:     /**
37:      * Changes control's type attribute.
38:      * @param  string
39:      * @return self
40:      */
41:     public function setType($type)
42:     {
43:         $this->control->type = $type;
44:         return $this;
45:     }
46: 
47: 
48:     /** @deprecated */
49:     public function setPasswordMode($mode = TRUE)
50:     {
51:         $this->control->type = $mode ? 'password' : 'text';
52:         return $this;
53:     }
54: 
55: 
56:     /**
57:      * Generates control's HTML element.
58:      * @return Nette\Utils\Html
59:      */
60:     public function getControl()
61:     {
62:         $control = parent::getControl();
63:         foreach ($this->getRules() as $rule) {
64:             if ($rule->isNegative || $rule->type !== Nette\Forms\Rule::VALIDATOR) {
65: 
66:             } elseif ($rule->operation === Nette\Forms\Form::RANGE && $control->type !== 'text') {
67:                 list($control->min, $control->max) = $rule->arg;
68: 
69:             } elseif ($rule->operation === Nette\Forms\Form::PATTERN) {
70:                 $control->pattern = $rule->arg;
71:             }
72:         }
73:         if ($control->type !== 'password') {
74:             $control->value = $this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value;
75:         }
76:         return $control;
77:     }
78: 
79: }
80: 
Nette 2.0 API documentation generated by ApiGen 2.8.0