Commit d6f2f7a6 authored by Henrik Elsner's avatar Henrik Elsner Committed by Christian Kuhn
Browse files

[FEATURE] Add "accept" as UploadViewHelper argument

Resolves: #95486
Releases: master
Change-Id: I6f9927e524e9d44e4e976ec948614d02d3a24edc
Reviewed-on: https://review.typo3.org/c/Packages/TYPO3.CMS/+/71452

Tested-by: core-ci's avatarcore-ci <typo3@b13.com>
Tested-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Tested-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
Reviewed-by: Christian Kuhn's avatarChristian Kuhn <lolli@schwarzbu.ch>
Reviewed-by: Stefan Bürk's avatarStefan Bürk <stefan@buerk.tech>
parent 04e55537
.. include:: ../../Includes.txt
==========================================================
Feature: #95486 - Add accept argument for UploadViewHelper
==========================================================
See :issue:`95486`
Description
===========
It is now possible to pass file types via "accept" as argument directly to the
UploadViewHelper.
Previously this had to be done by using "additionalAttributes".
This way it can be defined which file types are allowed for uploads,
to prevent unwanted file formats.
Example
=======
.. code-block:: html
<f:form.upload accept=".jpg,.png" />
.. index:: Fluid, ext:fluid
......@@ -45,6 +45,7 @@ class UploadViewHelper extends AbstractFormFieldViewHelper
parent::initializeArguments();
$this->registerTagAttribute('disabled', 'string', 'Specifies that the input element should be disabled when the page loads');
$this->registerTagAttribute('multiple', 'string', 'Specifies that the file input element should allow multiple selection of files');
$this->registerTagAttribute('accept', 'string', 'Specifies the allowed file extensions to upload via comma-separated list, example ".png,.gif"');
$this->registerArgument('errorClass', 'string', 'CSS class to set if there are errors for this ViewHelper', false, 'f3-form-error');
$this->registerUniversalTagAttributes();
}
......
......@@ -58,6 +58,16 @@ class UploadViewHelperTest extends FunctionalTestCase
self::assertSame('<input multiple="multiple" type="file" name="someName[]" />', $view->render());
}
/**
* @test
*/
public function renderCorrectlySetsAcceptAttribute(): void
{
$view = new StandaloneView();
$view->setTemplateSource('<f:form.upload accept=".jpg,.png" />');
self::assertSame('<input accept=".jpg,.png" type="file" name="" />', $view->render());
}
/**
* @test
*/
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment