Fórum

AutoFields Issue

Julian Vela, modificado 7 Anos atrás.

AutoFields Issue

New Member Postagens: 2 Data de Entrada: 07/07/16 Postagens Recentes
Hi,

Here seems to be an issue with Liferay Autofields input types other than text, textarea or password.
Adding rows with other input types does not work properly as rows duplication works fine but resulting input values does not reset so every new input is created with the previous content.

In order to solve it we have created a hook for auto_fields.js including url, number, email and date input types because of our particular purposes in _clearForm function (line 359) but it should work as well with any other html input types depending on your own needs.

Finally _clearForm function results as:

_clearForm: function(node) {
node.all('input, select, textarea').each(
function(item, index, collection) {
var type = item.getAttribute('type');
var tag = item.get('nodeName').toLowerCase();

if (type == 'text' || type == 'password' || tag == 'textarea' || type == 'url' || type == 'number' || type == 'email' || type == 'date') {
item.val('');
}
else if (type == 'checkbox' || type == 'radio') {
item.set('checked', false);
}
else if (tag == 'select') {
item.set('selectedIndex', -1);
}
}
);

AArray.each(
CSS_VALIDATION_HELPER_CLASSES,
function(item, index, collection) {
node.all('.' + item).removeClass(item);
}
);
}

Hoping it helps other development teams.

Regards!