[~FEATURE] Fluid (ViewHelpers): Adjusted AbstractFormViewHelper to be able to namespa...
[Packages/TYPO3.CMS.git] / typo3 / sysext / fluid / Classes / ViewHelpers / Form / UploadViewHelper.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 * A view helper which generates an <input type="file"> HTML element.
25 * Make sure to set enctype="multipart/form-data" on the form!
26 *
27 * = Examples =
28 *
29 * <code title="Example">
30 * <f:upload name="file" />
31 * </code>
32 *
33 * Output:
34 * <input type="file" name="file" />
35 *
36 * @version $Id: UploadViewHelper.php 2914 2009-07-28 18:26:38Z bwaidelich $
37 * @license http://www.gnu.org/licenses/lgpl.html GNU Lesser General Public License, version 3 or later
38 * @scope prototype
39 */
40 class Tx_Fluid_ViewHelpers_Form_UploadViewHelper extends Tx_Fluid_ViewHelpers_Form_AbstractFormFieldViewHelper {
41
42 /**
43 * @var string
44 */
45 protected $tagName = 'input';
46
47 /**
48 * Initialize the arguments.
49 *
50 * @return void
51 * @author Sebastian Kurfürst <sebastian@typo3.org>
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->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this view helper', FALSE, 'f3-form-error');
58 $this->registerUniversalTagAttributes();
59 }
60
61 /**
62 * Renders the upload field.
63 *
64 * @return string
65 * @author Sebastian Kurfürst <sebastian@typo3.org>
66 * @api
67 */
68 public function render() {
69 $this->tag->addAttribute('type', 'file');
70 $this->tag->addAttribute('name', $this->getName());
71
72 $this->setErrorClassAttribute();
73
74 return $this->tag->render();
75 }
76 }
77
78
79 ?>