Page 1 of 1

show_error improvement

Posted: 2018-10-09 00:25
by rprevost
Hello to you all,

The show_error function used in field content validation javascript is great.
However, the title of the modal window is sometimes "cryptic" especially if the name of the database name of the field looks like "sta_form_start_date". Since the caption of the field is nicer "Student Class Start Date", I wonder if it is possible to display the field caption instead of the field name in the show_error title.
I think that ergonomy of the tool would be greatly improved for end users.
I did not succeed in doing this (where is the list of methods and functions for fields?)
=====================================
function show_error(field, msg){
modal_window({
message: '<div class="alert alert-danger">' + msg + '</div>',
title: 'Error in ' + field,
close: function(){
$j('#' + field).focus();
$j('#' + field).parents('.form-group').addClass('has-error');
}
});
================================
Best regards,
RP

Re: show_error improvement

Posted: 2018-10-09 06:34
by pbottcher
Hi,

how do you call the function? The field variable is holding your titel, so if you pass the caption (which is the label) you should be fine.

Re: show_error improvement

Posted: 2018-10-11 13:54
by a.gneady
If I understand correctly, you wish to retrieve the field caption given the field name to pass to the title of the modal .. Here you go:

Code: Select all

title: 'Error in ' + $j('#' + field).parents('.form-group').find('label').text(),