DataTables - Editor - Field Errors Summary when using a Custom Template.
DataTables - Editor - Field Errors Summary when using a Custom Template.
washuit-iamm
Posts: 133Questions: 55Answers: 2
I am using a custom template via template: '#inventoryServerForm'
. Currently, I create my own field error summary like this:
// display editor ajax errors in a modal
editor.on('submitUnsuccessful', function (e, xhr, err, thrown, data) {
var $formErrors = $('#formErrors');
if (xhr != null && xhr.fieldErrors != null && xhr.fieldErrors.length) {
// Build summary
var $ul = $('<ul>');
for (var i = 0; i < xhr.fieldErrors.length; i++) {
$ul.append(`<li class="text-danger"><span>${xhr.fieldErrors[i].status}</span></li>`);
}
$formErrors.append($ul);
// Update form with BS4 stuff
// This is supposed to be fixed in 1.7.4
// https://datatables.net/forums/discussion/comment/131735#Comment_131735
$('.has-error')
.find('input')
.addClass('is-invalid');
}
});
I was hoping to be able to just add a placeholder for this somewhere, is there a more datatables way to do this?
This question has an accepted answers - jump to answer
This discussion has been closed.
Answers
Currently no. The template method allows you to structure the HTML around the fields that Editor creates, but the fields themselves are still created and populated by Editor. The structure they use is embedded into the code.
Allan