From 3df33f5e325679b501e4213c99259c1ecbcacfec Mon Sep 17 00:00:00 2001
From: Pascal Langhals <noreply@example.com>
Date: Wed, 21 Jun 2017 16:31:11 +0200
Subject: [PATCH] [TASK] Adding novalidate Attribute to Fluid Form ViewHelper

At the moment there is no possibility to disable the client side
validation for the fluid form tag.

Releases: master,8.7
Resolves: #81654
Change-Id: I8adbd51f0d50528e8a7d92fc4aeb2315aefafee7
Reviewed-on: https://review.typo3.org/53299
Tested-by: TYPO3com <no-reply@typo3.com>
Reviewed-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Wolfgang Klinger <wolfgang@wazum.com>
Tested-by: Wolfgang Klinger <wolfgang@wazum.com>
Tested-by: Georg Ringer <georg.ringer@gmail.com>
Reviewed-by: Henning Liebe <h.liebe@neusta.de>
Tested-by: Henning Liebe <h.liebe@neusta.de>
Reviewed-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com>
Reviewed-by: Matthias Vogel <typo3@kanti.de>
Tested-by: Sascha Rademacher <sascha.rademacher+typo3@gmail.com>
Reviewed-by: Steffen Frese <steffenf14@gmail.com>
Tested-by: Steffen Frese <steffenf14@gmail.com>
Reviewed-by: Frank Naegler <frank.naegler@typo3.org>
Tested-by: Frank Naegler <frank.naegler@typo3.org>
---
 ...gNovalidateAttributeToFluidFormViewHelper.rst | 16 ++++++++++++++++
 .../fluid/Classes/ViewHelpers/FormViewHelper.php |  6 ++++++
 .../Unit/ViewHelpers/FormViewHelperTest.php      |  1 +
 3 files changed, 23 insertions(+)
 create mode 100644 typo3/sysext/core/Documentation/Changelog/master/Feature-81654-AddingNovalidateAttributeToFluidFormViewHelper.rst

diff --git a/typo3/sysext/core/Documentation/Changelog/master/Feature-81654-AddingNovalidateAttributeToFluidFormViewHelper.rst b/typo3/sysext/core/Documentation/Changelog/master/Feature-81654-AddingNovalidateAttributeToFluidFormViewHelper.rst
new file mode 100644
index 000000000000..6c9a33c14852
--- /dev/null
+++ b/typo3/sysext/core/Documentation/Changelog/master/Feature-81654-AddingNovalidateAttributeToFluidFormViewHelper.rst
@@ -0,0 +1,16 @@
+.. include:: ../../Includes.txt
+
+======================================================================
+Feature: #81654 - Adding novalidate Attribute to Fluid Form ViewHelper
+======================================================================
+
+See :issue:`81654`
+
+Description
+===========
+
+Adding novalidate attribute to fluid form viewHelper to disable the browser form validation.
+The attribute novalidate is optional and can set with novalidate="1".The argument will
+converted to <form novalidate="novalidate">...</form>.
+
+.. index:: Fluid
diff --git a/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php b/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
index d7ae76b5f85b..05de4f7bc3d1 100644
--- a/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
+++ b/typo3/sysext/fluid/Classes/ViewHelpers/FormViewHelper.php
@@ -128,6 +128,7 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH
         $this->registerTagAttribute('onreset', 'string', 'JavaScript: On reset of the form');
         $this->registerTagAttribute('onsubmit', 'string', 'JavaScript: On submit of the form');
         $this->registerTagAttribute('target', 'string', 'Target attribute of the form');
+        $this->registerTagAttribute('novalidate', 'bool', 'Indicate that the form is not to be validated on submit.');
         $this->registerUniversalTagAttributes();
     }
 
@@ -144,6 +145,11 @@ class FormViewHelper extends \TYPO3\CMS\Fluid\ViewHelpers\Form\AbstractFormViewH
         } else {
             $this->tag->addAttribute('method', 'post');
         }
+
+        if ($this->arguments['novalidate'] === true) {
+            $this->tag->addAttribute('novalidate', 'novalidate');
+        }
+
         $this->addFormObjectNameToViewHelperVariableContainer();
         $this->addFormObjectToViewHelperVariableContainer();
         $this->addFieldNamePrefixToViewHelperVariableContainer();
diff --git a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php
index 7bdebe88dc45..e509e5b1ab0d 100644
--- a/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php
+++ b/typo3/sysext/fluid/Tests/Unit/ViewHelpers/FormViewHelperTest.php
@@ -54,6 +54,7 @@ class FormViewHelperTest extends ViewHelperBaseTestcase
         $viewHelper->expects($this->at(2))->method('registerTagAttribute')->with('name', 'string', $this->anything());
         $viewHelper->expects($this->at(3))->method('registerTagAttribute')->with('onreset', 'string', $this->anything());
         $viewHelper->expects($this->at(4))->method('registerTagAttribute')->with('onsubmit', 'string', $this->anything());
+        $viewHelper->expects($this->at(6))->method('registerTagAttribute')->with('novalidate', 'bool', $this->anything());
         $viewHelper->expects($this->once())->method('registerUniversalTagAttributes');
         $viewHelper->initializeArguments();
     }
-- 
GitLab