×

Please give details of the problem

Skip to content

How to get the list of invalid fields of a web interface

  • Create an HTML widget that will display the list of invalid fields of your web interface and set its id to id_html_invalid_widgets

  • Use the following Javascript code:

function displayInvalidFields(){
    var invalidWidgetsHtml = '<span style="color:red">';
    var invalidWidgetsInArray = {};
    RMPApplication.getInvalidWidgets().forEach(function(invalidWidget){
        try{
            if(invalidWidget.isIndexed()){
                // the widget is inside an Array
                var arrayId = invalidWidget.getParent().getName();
                if( !(invalidWidgetsInArray[arrayId]) ){
                    invalidWidgetsInArray[arrayId] = {};
                }
                if( !(invalidWidgetsInArray[arrayId][invalidWidget.getIndex()]) ){
                    invalidWidgetsInArray[arrayId][invalidWidget.getIndex()] = new Array;
                }
                var columnHeader = invalidWidget.getParent().getHeader( invalidWidget.getContainerIndex());
                invalidWidgetsInArray[arrayId][invalidWidget.getIndex()].push( columnHeader );


            }else if( invalidWidget.getParent()!=null && invalidWidget.getParent().getType()=="RMP_TabPanel" ){
                // the invalid widget is inside a TabPanel, we display the tab index that contains the widget and its label
                invalidWidgetsHtml += '<li>' + invalidWidget.getParent().getTabLabel( invalidWidget.getContainerIndex())   +' > ' + invalidWidget.getLabel() + '</li>';

            }else if( invalidWidget.getParent()!=null && invalidWidget.getParent().getType()=="RMP_Section" ){
                // we display the label of the section that contains the widget and its owne label
                invalidWidgetsHtml += '<li>' + invalidWidget.getParent().getLabel()   +' > ' + invalidWidget.getLabel() + '</li>';

            }else{
                invalidWidgetsHtml += '<li>' + invalidWidget.getLabel() + '</li>';
            }
        }catch(error){
            // display the raised errors on the browser console
            console.log(error);
        }
    });
    // we display the invalid fields of each line of the invalid arrays
    for ( var arrayId in invalidWidgetsInArray ){
        invalidWidgetsHtml += '<li>' + arrayId + '<ul>';
        for( var ligneIndex in invalidWidgetsInArray[arrayId] ){
            var invalidColumnHeaders = invalidWidgetsInArray[arrayId][ligneIndex]; 
            invalidWidgetsHtml += '<li> Ligne ' + ligneIndex + ': '+ invalidColumnHeaders + '</li>';
        }
        invalidWidgetsHtml += '</ul></li>';
    }
    invalidWidgetsHtml += '</span>';
    //display the invalid fields in an Html widget
    id_html_invalid_widgets.setHtml(invalidWidgetsHtml);
}
  • Call displayInvalidWidgets() unction whenever you want to display the list of invalid fields of your web interface

how-to-use-google-table

Note: You can customize with CSS

A non valid field is a field that either:

  • don't respect its valid rule
  • is required and is not filled in