From f7c7fc5dc4a0645db8a8abb6af8f681d27300ca1 Mon Sep 17 00:00:00 2001 From: Denis Flaven Date: Tue, 10 Mar 2015 15:34:04 +0000 Subject: [PATCH] Support several sets of forbidden values (with a specific "reason" message) per field. SVN:trunk[3500] --- application/forms.class.inc.php | 16 ++++++---------- js/property_field.js | 13 ++++++++----- 2 files changed, 14 insertions(+), 15 deletions(-) diff --git a/application/forms.class.inc.php b/application/forms.class.inc.php index 1f30e4d93..4f4462952 100644 --- a/application/forms.class.inc.php +++ b/application/forms.class.inc.php @@ -867,13 +867,11 @@ class DesignerTextField extends DesignerFormField { protected $sValidationPattern; protected $aForbiddenValues; - protected $sExplainForbiddenValues; public function __construct($sCode, $sLabel = '', $defaultValue = '') { parent::__construct($sCode, $sLabel, $defaultValue); $this->sValidationPattern = ''; - $this->aForbiddenValues = null; - $this->sExplainForbiddenValues = null; + $this->aForbiddenValues = array(); } public function SetValidationPattern($sValidationPattern) @@ -883,17 +881,17 @@ class DesignerTextField extends DesignerFormField public function SetForbiddenValues($aValues, $sExplain) { - $this->aForbiddenValues = $aValues; + $aForbiddenValues = $aValues; $iDefaultKey = array_search($this->defaultValue, $this->aForbiddenValues); if ($iDefaultKey !== false) { // The default (current) value is always allowed... - unset($this->aForbiddenValues[$iDefaultKey]); + unset($aForbiddenValues[$iDefaultKey]); } - $this->sExplainForbiddenValues = $sExplain; + $this->aForbiddenValues[] = array('values' => $aForbiddenValues, 'message' => $sExplain); } public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog') @@ -911,17 +909,15 @@ class DesignerTextField extends DesignerFormField if (is_array($this->aForbiddenValues)) { $sForbiddenValues = json_encode($this->aForbiddenValues); - $sExplainForbiddenValues = addslashes($this->sExplainForbiddenValues); } else { - $sForbiddenValues = 'null'; - $sExplainForbiddenValues = 'null'; + $sForbiddenValues = '[]'; //Empty JS array } $sMandatory = $this->bMandatory ? 'true' : 'false'; $oP->add_ready_script( <<