‪TYPO3CMS  10.4
UploadViewHelper.php
Go to the documentation of this file.
1 <?php
2 
3 /*
4  * This file is part of the TYPO3 CMS project.
5  *
6  * It is free software; you can redistribute it and/or modify it under
7  * the terms of the GNU General Public License, either version 2
8  * of the License, or any later version.
9  *
10  * For the full copyright and license information, please read the
11  * LICENSE.txt file that was distributed with this source code.
12  *
13  * The TYPO3 project - inspiring people to share!
14  */
15 
17 
34 {
38  protected ‪$tagName = 'input';
39 
43  public function ‪initializeArguments()
44  {
45  parent::initializeArguments();
46  $this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
47  $this->registerTagAttribute('multiple', 'string', 'Specifies that the file input element should allow multiple selection of files');
48  $this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this ViewHelper', false, 'f3-form-error');
49  $this->registerUniversalTagAttributes();
50  }
51 
57  public function ‪render()
58  {
59  $name = $this->‪getName();
60  $allowedFields = ['name', 'type', 'tmp_name', 'error', 'size'];
61  foreach ($allowedFields as $fieldName) {
62  $this->‪registerFieldNameForFormTokenGeneration($name . '[' . $fieldName . ']');
63  }
64  $this->tag->addAttribute('type', 'file');
65 
66  if (isset($this->arguments['multiple'])) {
67  $this->tag->addAttribute('name', $name . '[]');
68  } else {
69  $this->tag->addAttribute('name', $name);
70  }
71 
73  return $this->tag->render();
74  }
75 }
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\setErrorClassAttribute
‪setErrorClassAttribute()
Definition: AbstractFormFieldViewHelper.php:331
‪TYPO3\CMS\Fluid\ViewHelpers\Form\UploadViewHelper\render
‪string render()
Definition: UploadViewHelper.php:56
‪TYPO3\CMS\Fluid\ViewHelpers\Form
Definition: AbstractFormFieldViewHelper.php:16
‪TYPO3\CMS\Fluid\ViewHelpers\Form\UploadViewHelper
Definition: UploadViewHelper.php:34
‪TYPO3\CMS\Fluid\ViewHelpers\Form\UploadViewHelper\$tagName
‪string $tagName
Definition: UploadViewHelper.php:37
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewHelper\registerFieldNameForFormTokenGeneration
‪registerFieldNameForFormTokenGeneration($fieldName)
Definition: AbstractFormViewHelper.php:106
‪TYPO3\CMS\Fluid\ViewHelpers\Form\UploadViewHelper\initializeArguments
‪initializeArguments()
Definition: UploadViewHelper.php:42
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper
Definition: AbstractFormFieldViewHelper.php:30
‪TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormFieldViewHelper\getName
‪string getName()
Definition: AbstractFormFieldViewHelper.php:90