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
  • PHP

Classes

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