|
@@ -867,13 +867,11 @@ class DesignerTextField extends DesignerFormField
|
|
{
|
|
{
|
|
protected $sValidationPattern;
|
|
protected $sValidationPattern;
|
|
protected $aForbiddenValues;
|
|
protected $aForbiddenValues;
|
|
- protected $sExplainForbiddenValues;
|
|
|
|
public function __construct($sCode, $sLabel = '', $defaultValue = '')
|
|
public function __construct($sCode, $sLabel = '', $defaultValue = '')
|
|
{
|
|
{
|
|
parent::__construct($sCode, $sLabel, $defaultValue);
|
|
parent::__construct($sCode, $sLabel, $defaultValue);
|
|
$this->sValidationPattern = '';
|
|
$this->sValidationPattern = '';
|
|
- $this->aForbiddenValues = null;
|
|
|
|
- $this->sExplainForbiddenValues = null;
|
|
|
|
|
|
+ $this->aForbiddenValues = array();
|
|
}
|
|
}
|
|
|
|
|
|
public function SetValidationPattern($sValidationPattern)
|
|
public function SetValidationPattern($sValidationPattern)
|
|
@@ -883,17 +881,17 @@ class DesignerTextField extends DesignerFormField
|
|
|
|
|
|
public function SetForbiddenValues($aValues, $sExplain)
|
|
public function SetForbiddenValues($aValues, $sExplain)
|
|
{
|
|
{
|
|
- $this->aForbiddenValues = $aValues;
|
|
|
|
|
|
+ $aForbiddenValues = $aValues;
|
|
|
|
|
|
$iDefaultKey = array_search($this->defaultValue, $this->aForbiddenValues);
|
|
$iDefaultKey = array_search($this->defaultValue, $this->aForbiddenValues);
|
|
if ($iDefaultKey !== false)
|
|
if ($iDefaultKey !== false)
|
|
{
|
|
{
|
|
// The default (current) value is always allowed...
|
|
// 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')
|
|
public function Render(WebPage $oP, $sFormId, $sRenderMode='dialog')
|
|
@@ -911,17 +909,15 @@ class DesignerTextField extends DesignerFormField
|
|
if (is_array($this->aForbiddenValues))
|
|
if (is_array($this->aForbiddenValues))
|
|
{
|
|
{
|
|
$sForbiddenValues = json_encode($this->aForbiddenValues);
|
|
$sForbiddenValues = json_encode($this->aForbiddenValues);
|
|
- $sExplainForbiddenValues = addslashes($this->sExplainForbiddenValues);
|
|
|
|
}
|
|
}
|
|
else
|
|
else
|
|
{
|
|
{
|
|
- $sForbiddenValues = 'null';
|
|
|
|
- $sExplainForbiddenValues = 'null';
|
|
|
|
|
|
+ $sForbiddenValues = '[]'; //Empty JS array
|
|
}
|
|
}
|
|
$sMandatory = $this->bMandatory ? 'true' : 'false';
|
|
$sMandatory = $this->bMandatory ? 'true' : 'false';
|
|
$oP->add_ready_script(
|
|
$oP->add_ready_script(
|
|
<<<EOF
|
|
<<<EOF
|
|
-$('#$sId').bind('change keyup validate', function() { ValidateWithPattern('$sId', $sMandatory, '$sPattern', $(this).closest('form').attr('id'), $sForbiddenValues, '$sExplainForbiddenValues'); } );
|
|
|
|
|
|
+$('#$sId').bind('change keyup validate', function() { ValidateWithPattern('$sId', $sMandatory, '$sPattern', $(this).closest('form').attr('id'), $sForbiddenValues); } );
|
|
{
|
|
{
|
|
var myTimer = null;
|
|
var myTimer = null;
|
|
$('#$sId').bind('keyup', function() { clearTimeout(myTimer); myTimer = setTimeout(function() { $('#$sId').trigger('change', {} ); }, 100); });
|
|
$('#$sId').bind('keyup', function() { clearTimeout(myTimer); myTimer = setTimeout(function() { $('#$sId').trigger('change', {} ); }, 100); });
|