From 4a4c08cf11fb1038ba347045e80a4cbc48ce2e33 Mon Sep 17 00:00:00 2001
From: elvill <elias.villiger@uzh.ch>
Date: Thu, 8 Feb 2018 13:09:28 +0100
Subject: [PATCH] Feature #5392 - Violate message with expected date format

---
 extension/qfq/qfq/AbstractBuildForm.php | 5 ++++-
 extension/qfq/qfq/helper/Support.php    | 2 ++
 2 files changed, 6 insertions(+), 1 deletion(-)

diff --git a/extension/qfq/qfq/AbstractBuildForm.php b/extension/qfq/qfq/AbstractBuildForm.php
index b0c3e8f28..deaac4be8 100644
--- a/extension/qfq/qfq/AbstractBuildForm.php
+++ b/extension/qfq/qfq/AbstractBuildForm.php
@@ -3177,7 +3177,6 @@ abstract class AbstractBuildForm {
         // 'maxLength' needs an upper 'L': naming convention for DB tables!
         $attribute .= $this->getAttributeList($formElement, ['size', 'maxLength']);
         $attribute .= Support::doAttribute('value', htmlentities($value), false);
-        $attribute .= $this->getAttributeList($formElement, [F_FE_DATA_PATTERN_ERROR, F_FE_DATA_REQUIRED_ERROR, F_FE_DATA_MATCH_ERROR, F_FE_DATA_ERROR]);
 
         if ($formElement[FE_PLACEHOLDER] == '') {
             $timePattern = ($formElement[FE_SHOW_SECONDS] == 1) ? 'hh:mm:ss' : 'hh:mm';
@@ -3198,6 +3197,10 @@ abstract class AbstractBuildForm {
             $formElement[FE_PLACEHOLDER] = $placeholder;
         }
 
+        if ($formElement[F_FE_DATA_PATTERN_ERROR] == '')
+            $formElement[F_FE_DATA_PATTERN_ERROR] = "Please match this format: $placeholder";
+        $attribute .= $this->getAttributeList($formElement, [F_FE_DATA_PATTERN_ERROR, F_FE_DATA_REQUIRED_ERROR, F_FE_DATA_MATCH_ERROR, F_FE_DATA_ERROR]);
+
         $attribute .= $this->getAttributeList($formElement, [FE_INPUT_AUTOCOMPLETE, 'autofocus', 'placeholder']);
         $attribute .= Support::doAttribute('data-load', ($formElement[FE_DYNAMIC_UPDATE] === 'yes') ? 'data-load' : '');
         $attribute .= Support::doAttribute('title', $formElement[FE_TOOLTIP]);
diff --git a/extension/qfq/qfq/helper/Support.php b/extension/qfq/qfq/helper/Support.php
index a8a024a8c..7e6c560a2 100644
--- a/extension/qfq/qfq/helper/Support.php
+++ b/extension/qfq/qfq/helper/Support.php
@@ -798,6 +798,8 @@ class Support {
         }
         self::setIfNotSet($formElement, FE_DECIMAL_FORMAT);
 
+        self::setIfNotSet($formElement, F_FE_DATA_PATTERN_ERROR);
+
         return $formElement;
     }
 
-- 
GitLab