Support for Date and DateTime in portal

Fixed form validation on portal

SVN:trunk[4025]
This commit is contained in:
Guillaume Lajarige
2016-05-03 16:08:09 +00:00
parent 2513f0489c
commit 79f73256d7
3 changed files with 10 additions and 8 deletions

View File

@@ -122,7 +122,6 @@ $(function()
// Doing data validation
if(this.options.validators !== null)
{
var bMandatory = (this.options.validators.mandatory !== undefined);
// Extracting value for the field
var oValue = this.element.triggerHandler('get_current_value');
if(oValue === null)
@@ -130,19 +129,22 @@ $(function()
console.log('Form field : Warning, there was no value for "'+this.element.attr('data-field-id')+'"');
return oResult;
}
var aValueKeys = Object.keys(oValue);
var bMandatory = (this.options.validators.mandatory !== undefined);
var bEmpty = ($.isArray(oValue)) ? (oValue.length === 0) : (oValue === '' || oValue === undefined);
var value = oValue;
// This is just a safety check in case a field doesn't always return an object when no value assigned, so we have to check the mandatory validator here...
// ... But this should never happen.
if( (aValueKeys.length === 0) && bMandatory )
//if( (aValueKeys.length === 0) && bMandatory )
if( bEmpty && bMandatory )
{
oResult.is_valid = false;
oResult.error_messages.push(this.options.validators.mandatory.message);
}
// ... Otherwise, we check every validators
else if(aValueKeys.length > 0)
else
{
var value = oValue[aValueKeys[0]];
for(var sValidatorType in this.options.validators)
{
var oValidator = this.options.validators[sValidatorType];
@@ -186,7 +188,7 @@ $(function()
}
}
else if($.isArray(value))
{
{
for(var i in value)
{
if(value[i] === 'string' && !oRegExp.test(value))

View File

@@ -86,7 +86,7 @@ EOF
// Rendering table widget
// - Vars
$sEmptyTableLabel = htmlentities(Dict::S('UI:Message:EmptyList:UseAdd'), ENT_QUOTES, 'UTF-8');
$sEmptyTableLabel = htmlentities(Dict::S( ($this->oField->GetReadOnly()) ? 'Portal:Datatables:Language:EmptyTable' : 'UI:Message:EmptyList:UseAdd'), ENT_QUOTES, 'UTF-8');
$sSelectionOptionHtml = ($this->oField->GetReadOnly()) ? 'false' : '{"style": "multi"}';
$sSelectionInputHtml = ($this->oField->GetReadOnly()) ? '' : '<span class="row_input"><input type="checkbox" name="' . $this->oField->GetId() . '" /></span>';
// - Output

View File

@@ -166,7 +166,7 @@ EOF
{
// Note : The test is a double equal on purpose as the type of the value received from the XHR is not always the same as the type of the allowed values. (eg : string vs int)
$sSelectedAtt = ($this->oField->GetCurrentValue() == $sChoice) ? 'selected' : '';
$oOutput->AddHtml('<option value="' . $sChoice . '" ' . $sSelectedAtt . ' >')->AddHtml($sLabel, true)->AddHtml('</option>');
$oOutput->AddHtml('<option value="' . $sChoice . '" ' . $sSelectedAtt . ' >')->AddHtml($sLabel)->AddHtml('</option>');
}
$oOutput->AddHtml('</select>');
$oOutput->AddHtml('</div>');