Packages

  • 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

  • Button
  • Checkbox
  • FormControl
  • HiddenField
  • ImageButton
  • MultiSelectBox
  • RadioList
  • SelectBox
  • SubmitButton
  • TextArea
  • TextBase
  • TextInput
  • UploadControl
  • Overview
  • Package
  • 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:  * @package Nette\Forms\Controls
11:  */
12: 
13: 
14: 
15: /**
16:  * Single line text input control.
17:  *
18:  * @author     David Grudl
19:  * @property-write $type
20:  * @package Nette\Forms\Controls
21:  */
22: class TextInput extends TextBase
23: {
24: 
25:     /**
26:      * @param  string  label
27:      * @param  int  width of the control
28:      * @param  int  maximum number of characters the user may enter
29:      */
30:     public function __construct($label = NULL, $cols = NULL, $maxLength = NULL)
31:     {
32:         parent::__construct($label);
33:         $this->control->type = 'text';
34:         $this->control->size = $cols;
35:         $this->control->maxlength = $maxLength;
36:     }
37: 
38: 
39:     /**
40:      * Changes control's type attribute.
41:      * @param  string
42:      * @return self
43:      */
44:     public function setType($type)
45:     {
46:         $this->control->type = $type;
47:         return $this;
48:     }
49: 
50: 
51:     /** @deprecated */
52:     public function setPasswordMode($mode = TRUE)
53:     {
54:         $this->control->type = $mode ? 'password' : 'text';
55:         return $this;
56:     }
57: 
58: 
59:     /**
60:      * Generates control's HTML element.
61:      * @return Html
62:      */
63:     public function getControl()
64:     {
65:         $control = parent::getControl();
66:         foreach ($this->getRules() as $rule) {
67:             if ($rule->isNegative || $rule->type !== Rule::VALIDATOR) {
68: 
69:             } elseif ($rule->operation === Form::RANGE && $control->type !== 'text') {
70:                 list($control->min, $control->max) = $rule->arg;
71: 
72:             } elseif ($rule->operation === Form::PATTERN) {
73:                 $control->pattern = $rule->arg;
74:             }
75:         }
76:         if ($control->type !== 'password') {
77:             $control->value = $this->getValue() === '' ? $this->translate($this->emptyValue) : $this->value;
78:         }
79:         return $control;
80:     }
81: 
82: }
83: 
Nette Framework 2.0.11 (for PHP 5.2, un-prefixed) API API documentation generated by ApiGen 2.8.0