Hi.
I have a tab separated active form:
As you can see, here there are 3 tab: "Default - data", "Place" and "Service".
But unfortunately there are 4-5 error massages under the "Place" tab and those error messages are not shown by the validation function of activeform.
For this problem I created a jQuery function which will "show the error message list.". Because this is a big problem (not user friendly - user cannot find the error messages).
If you are interesting, you can see the code:
/**
* Validation.
* Search for validation error messages under all tab pane and shows in a list.
* This list contains navigation to the non valid input|select element.
*
* @returns {void}
*/
function showErrorMessages() {
var errorList = $('<ul></ul>');
$(".has-error").each(function(index, element){
var item = $(element);
var elementId = item.children("input, select").attr("id");
var elementText = item.children(".help-block").text();
var elementParentId = item.parent().attr("id");
errorList.append(
'<li onclick="navigateToElement('+ elementParentId + ', ' + elementId + ')" style="cursor:pointer;">'
+ elementText +
'</li>'
);
});
$(".error-messages-container").append($errorList);
}
/**
* Navigate to element.
* It opens the tab pane and then focus on the element.
*
* @param {number} elementParentId
* @param {number} elementId
* @returns {void}
*/
function navigateToElement(elementParentId, elementId) {
$("a[href='#" + elementParentId + "']").click();
$("#" + elementId).focus();
}
But the main problem, I do not know how I can subscribe this “showErrorMessages” function to run after yii’s activeform validation function!
My function has to run after validation function run (of activeform). Anybody know how can I subscribe on this event?