[~FEATURE] Fluid (ViewHelpers): Adjusted AbstractFormViewHelper to be able to namespa...
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Form / TextboxViewHelper.php
1 <?php
2
3 /* *
4 * This script belongs to the FLOW3 package "Fluid". *
5 * *
6 * It is free software; you can redistribute it and/or modify it under *
7 * the terms of the GNU Lesser General Public License as published by the *
8 * Free Software Foundation, either version 3 of the License, or (at your *
9 * option) any later version. *
10 * *
11 * This script is distributed in the hope that it will be useful, but *
12 * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN- *
13 * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser *
14 * General Public License for more details. *
15 * *
16 * You should have received a copy of the GNU Lesser General Public *
17 * License along with the script. *
18 * If not, see http://www.gnu.org/licenses/lgpl.html *
19 * *
20 * The TYPO3 project - inspiring people to share! *
21 * */
22
23 /**
24 * View Helper which creates a simple Text Box (<input type="text">).
25 *
26 * = Examples =
27 *
28 * <code title="Example">
29 * <f:textbox name="myTextBox" value="default value" />
30 * </code>
31 *
32 * Output:
33 * <input type="text" name="myTextBox" value="default value" />
34 *
35 * @version $Id: TextboxViewHelper.php 2914 2009-07-28 18:26:38Z bwaidelich $
36 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
37 * @scope prototype
38 */
39 class Tx_Fluid_ViewHelpers_Form_TextboxViewHelper extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper {
40
41 /**
42 * @var string
43 */
44 protected $tagName = 'input';
45
46 /**
47 * Initialize the arguments.
48 *
49 * @return void
50 * @author Sebastian Kurfürst <sebastian@typo3.org>
51 * @author Christopher Hlubek <hlubek@networkteam.com>
52 * @api
53 */
54 public function initializeArguments() {
55 parent::initializeArguments();
56 $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
57 $this->registerTagAttribute('maxlength', 'int', 'The maxlength attribute of the input field (will not be validated)');
58 $this->registerTagAttribute('readonly', 'string', 'The readonly attribute of the input field');
59 $this->registerTagAttribute('size', 'int', 'The size of the input field');
60 $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
61 $this->registerUniversalTagAttributes();
62 }
63
64 /**
65 * Renders the textbox.
66 *
67 * @return string
68 * @author Sebastian Kurfürst <sebastian@typo3.org>
69 * @api
70 */
71 public function render() {
72 $this->tag->addAttribute('type', 'text');
73 $this->tag->addAttribute('name', $this->getName());
74 $this->tag->addAttribute('value', $this->getValue());
75
76 $this->setErrorClassAttribute();
77
78 return $this->tag->render();
79 }
80
81 }
82
83 ?>