Update JS that adds classes for modal form errors
The JS that processes json error messages for modal forms was not searching for or adding the correct classes to the HTML for display the errors. This patch updates the JS so that once processed the HTML matches the HTML that is returned in the non-json response of the form. Change-Id: Ib5ef39d02194ec6c31d69f534831bb0d28e0884c Closes-Bug: 1443428
This commit is contained in:
parent
602c46e89f
commit
6977239374
@ -70,11 +70,11 @@ horizon.modals.init_wizard = function () {
|
||||
}
|
||||
|
||||
// Clear old errors.
|
||||
$form.find('td.actions div.alert-danger').remove();
|
||||
$form.find('.form-group.error').each(function () {
|
||||
$form.find('div.row div.alert-danger').remove();
|
||||
$form.find('.form-group.has-error').each(function () {
|
||||
var $group = $(this);
|
||||
$group.removeClass('error');
|
||||
$group.find('span.help-block.error').remove();
|
||||
$group.removeClass('has-error');
|
||||
$group.find('span.help-block.alert').remove();
|
||||
});
|
||||
|
||||
// Send the data for validation.
|
||||
@ -103,7 +103,7 @@ horizon.modals.init_wizard = function () {
|
||||
if (field === '__all__') {
|
||||
// Add global errors.
|
||||
$.each(errors, function (index, error) {
|
||||
$fieldset.find('td.actions').prepend(
|
||||
$fieldset.find('div.row').prepend(
|
||||
'<div class="alert alert-message alert-danger">' +
|
||||
error + '</div>');
|
||||
});
|
||||
@ -112,10 +112,10 @@ horizon.modals.init_wizard = function () {
|
||||
}
|
||||
// Add field errors.
|
||||
$field = $fieldset.find('[name="' + field + '"]');
|
||||
$field.closest('.form-group').addClass('error');
|
||||
$field.closest('.form-group').addClass('has-error');
|
||||
$.each(errors, function (index, error) {
|
||||
$field.before(
|
||||
'<span class="help-block error">' +
|
||||
$field.after(
|
||||
'<span class="help-block alert alert-danger">' +
|
||||
error + '</span>');
|
||||
});
|
||||
// Focus the first invalid field.
|
||||
|
Loading…
Reference in New Issue
Block a user