[FEATURE] Add placeholder argument to VH for Textarea and Textfield
authorWouter Wolters <typo3@wouterwolters.nl>
Sun, 28 Apr 2013 21:44:28 +0000 (23:44 +0200)
committerStefan Neufeind <typo3.neufeind@speedpartner.de>
Sun, 12 May 2013 21:33:19 +0000 (23:33 +0200)
Change-Id: I8c4cc22e10ce2991f48c32b7934bf01346f8aecf
Resolves: #45960
Releases: 6.2
Reviewed-on: https://review.typo3.org/20281
Reviewed-by: Wouter Wolters
Tested-by: Wouter Wolters
Reviewed-by: Helmut Hummel
Reviewed-by: Stefan Neufeind
Tested-by: Stefan Neufeind
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextareaViewHelper.php
typo3/sysext/fluid/Classes/ViewHelpers/Form/TextfieldViewHelper.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextareaViewHelperTest.php
typo3/sysext/fluid/Tests/Unit/ViewHelpers/Form/TextfieldViewHelperTest.php

index 1d9d069..f3aca57 100644 (file)
@@ -44,6 +44,7 @@ class TextareaViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormF
                $this->registerTagAttribute('rows', 'int', 'The number of rows of a text area');
                $this->registerTagAttribute('cols', 'int', 'The number of columns of a text area');
                $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
+               $this->registerTagAttribute('placeholder', 'string', 'The placeholder of the textarea');
                $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
                $this->registerUniversalTagAttributes();
        }
index 9771a14..4a645a2 100644 (file)
@@ -44,6 +44,7 @@ class TextfieldViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractForm
                $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->registerTagAttribute('placeholder', 'string', 'The placeholder of the textfield');
                $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
                $this->registerUniversalTagAttributes();
        }
index 778bb0d..458efed 100644 (file)
@@ -96,6 +96,27 @@ class TextareaViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\For
                $this->viewHelper->initialize();
                $this->viewHelper->render();
        }
+
+       /**
+        * @test
+        */
+       public function renderAddsPlaceholder() {
+               $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('addAttribute', 'setContent', 'render'), array(), '', FALSE);
+               $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('placeholder', 'SomePlaceholder');
+               $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('name', 'NameOfTextarea');
+               $mockTagBuilder->expects($this->once())->method('render');
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $arguments = array(
+                       'name' => 'NameOfTextarea',
+                       'placeholder' => 'SomePlaceholder'
+               );
+               $this->viewHelper->setArguments($arguments);
+
+               $this->viewHelper->setViewHelperNode(new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode());
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
 }
 
 ?>
\ No newline at end of file
index dd0fa5d..a367d98 100644 (file)
@@ -75,6 +75,29 @@ class TextfieldViewHelperTest extends \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Fo
                $this->viewHelper->expects($this->once())->method('setErrorClassAttribute');
                $this->viewHelper->render();
        }
+
+
+       /**
+        * @test
+        */
+       public function renderAddsPlaceholder() {
+               $mockTagBuilder = $this->getMock('TYPO3\\CMS\\Fluid\\Core\\ViewHelper\\TagBuilder', array('addAttribute', 'setContent', 'render'), array(), '', FALSE);
+               $mockTagBuilder->expects($this->at(0))->method('addAttribute')->with('placeholder', 'SomePlaceholder');
+               $mockTagBuilder->expects($this->at(1))->method('addAttribute')->with('type', 'text');
+               $mockTagBuilder->expects($this->at(2))->method('addAttribute')->with('name', 'NameOfTextfield');
+               $mockTagBuilder->expects($this->once())->method('render');
+               $this->viewHelper->injectTagBuilder($mockTagBuilder);
+
+               $arguments = array(
+                       'name' => 'NameOfTextfield',
+                       'placeholder' => 'SomePlaceholder'
+               );
+               $this->viewHelper->setArguments($arguments);
+
+               $this->viewHelper->setViewHelperNode(new \TYPO3\CMS\Fluid\Tests\Unit\ViewHelpers\Form\Fixtures\EmptySyntaxTreeNode());
+               $this->viewHelper->initialize();
+               $this->viewHelper->render();
+       }
 }
 
 ?>
\ No newline at end of file