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