[+FEATURE] Fluid (ViewHelpers): Added a Form Password ViewHelper, to generate passwor...
authorSebastian Kurfürst <sebastian@typo3.org>
Wed, 16 Sep 2009 10:40:53 +0000 (10:40 +0000)
committerSebastian Kurfürst <sebastian@typo3.org>
Wed, 16 Sep 2009 10:40:53 +0000 (10:40 +0000)
typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php [new file with mode: 0644]

diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/Form/PasswordViewHelper.php
new file mode 100644 (file)
index 0000000..5a74719
--- /dev/null
@@ -0,0 +1,83 @@
+<?php
+
+/*                                                                        *
+ * This script belongs to the FLOW3 package "Fluid".                      *
+ *                                                                        *
+ * It is free software; you can redistribute it and/or modify it under    *
+ * the terms of the GNU Lesser General Public License as published by the *
+ * Free Software Foundation, either version 3 of the License, or (at your *
+ * option) any later version.                                             *
+ *                                                                        *
+ * This script is distributed in the hope that it will be useful, but     *
+ * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHAN-    *
+ * TABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU Lesser       *
+ * General Public License for more details.                               *
+ *                                                                        *
+ * You should have received a copy of the GNU Lesser General Public       *
+ * License along with the script.                                         *
+ * If not, see http://www.gnu.org/licenses/lgpl.html                      *
+ *                                                                        *
+ * The TYPO3 project - inspiring people to share!                         *
+ *                                                                        */
+
+/**
+ * View Helper which creates a simple Password Text Box (<input type="password">).
+ *
+  * = Examples =
+ *
+ * <code title="Example">
+ * <f:form.password name="myPassword" />
+ * </code>
+ *
+ * Output:
+ * <input type="password" name="myPassword" value="default value" />
+ *
+ * @version $Id: TextboxViewHelper.php 3109 2009-08-31 17:22:46Z bwaidelich $
+ * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
+ * @scope prototype
+ */
+class Tx_Fluid_ViewHelpers_Form_PasswordViewHelper extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper {
+
+       /**
+        * @var string
+        */
+       protected $tagName = 'input';
+
+       /**
+        * Initialize the arguments.
+        *
+        * @return void
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @author Christopher Hlubek <hlubek@networkteam.com>
+        * @api
+        */
+       public function initializeArguments() {
+               parent::initializeArguments();
+               $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
+               $this->registerTagAttribute('maxlength', 'int', 'The maxlength attribute of the input field (will not be validated)');
+               $this->registerTagAttribute('readonly', 'string', 'The readonly attribute of the input field');
+               $this->registerTagAttribute('size', 'int', 'The size of the input field');
+               $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
+               $this->registerUniversalTagAttributes();
+       }
+
+       /**
+        * Renders the textbox.
+        *
+        * @return string
+        * @author Sebastian Kurfürst <sebastian@typo3.org>
+        * @api
+        */
+       public function render() {
+               $this->tag->addAttribute('type', 'password');
+               $this->tag->addAttribute('name', $this->getName());
+               $this->tag->addAttribute('value', $this->getValue());
+
+               $this->setErrorClassAttribute();
+
+               return $this->tag->render();
+       }
+
+}
+
+?>
\ No newline at end of file