Permalink
Browse files

Show the correct date/time format when validating front end forms (see

  • Loading branch information...
1 parent 0bf3365 commit a7cdf4383ca3f70b11b5197398ea41f0e67360fc @leofeyer leofeyer committed Jan 14, 2013
Showing with 34 additions and 22 deletions.
  1. +3 −0 CHANGELOG.md
  2. +31 −22 system/libraries/Widget.php
View
@@ -5,6 +5,9 @@ Version 2.11.9 (2013-XX-XX)
---------------------------
### Fixed
+Show the correct date/time format when validating front end forms (see #5238).
+
+### Fixed
Unset non-existing fields when restoring versions (see #5219).
@@ -604,6 +604,8 @@ protected function getPost($strKey)
*/
protected function validator($varInput)
{
+ global $objPage;
+
if (is_array($varInput))
{
foreach ($varInput as $k=>$v)
@@ -715,50 +717,57 @@ protected function validator($varInput)
// Check whether the current value is a valid date format
case 'date':
$objDate = new Date();
+ $strFormat = (TL_MODE == 'FE') ? $objPage->dateFormat : $GLOBALS['TL_CONFIG']['dateFormat'];
- if (!preg_match('~^'. $objDate->getRegexp($GLOBALS['TL_CONFIG']['dateFormat']) .'$~i', $varInput))
+ if (!preg_match('~^'. $objDate->getRegexp($strFormat) .'$~i', $varInput))
{
- $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], $objDate->getInputFormat($GLOBALS['TL_CONFIG']['dateFormat'])));
+ $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['date'], $objDate->getInputFormat($strFormat)));
}
-
- // Validate the date (see #5086)
- try
- {
- new Date($varInput);
- }
- catch (Exception $e)
+ else
{
- $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
+ // Validate the date (see #5086)
+ try
+ {
+ new Date($varInput);
+ }
+ catch (Exception $e)
+ {
+ $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
+ }
}
break;
// Check whether the current value is a valid time format
case 'time':
$objDate = new Date();
+ $strFormat = (TL_MODE == 'FE') ? $objPage->timeFormat : $GLOBALS['TL_CONFIG']['timeFormat'];
- if (!preg_match('~^'. $objDate->getRegexp($GLOBALS['TL_CONFIG']['timeFormat']) .'$~i', $varInput))
+ if (!preg_match('~^'. $objDate->getRegexp($strFormat) .'$~i', $varInput))
{
- $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['time'], $objDate->getInputFormat($GLOBALS['TL_CONFIG']['timeFormat'])));
+ $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['time'], $objDate->getInputFormat($strFormat)));
}
break;
// Check whether the current value is a valid date and time format
case 'datim':
$objDate = new Date();
+ $strFormat = (TL_MODE == 'FE') ? $objPage->datimFormat : $GLOBALS['TL_CONFIG']['datimFormat'];
- if (!preg_match('~^'. $objDate->getRegexp($GLOBALS['TL_CONFIG']['datimFormat']) .'$~i', $varInput))
+ if (!preg_match('~^'. $objDate->getRegexp($strFormat) .'$~i', $varInput))
{
- $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['dateTime'], $objDate->getInputFormat($GLOBALS['TL_CONFIG']['datimFormat'])));
+ $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['dateTime'], $objDate->getInputFormat($strFormat)));
}
-
- // Validate the date (see #5086)
- try
- {
- new Date($varInput);
- }
- catch (Exception $e)
+ else
{
- $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
+ // Validate the date (see #5086)
+ try
+ {
+ new Date($varInput);
+ }
+ catch (Exception $e)
+ {
+ $this->addError(sprintf($GLOBALS['TL_LANG']['ERR']['invalidDate'], $varInput));
+ }
}
break;

0 comments on commit a7cdf43

Please sign in to comment.