fix error key / field input detection (field's name include -role when specified, the error key *may* include it
--- a/web/data/cubicweb.edition.js Wed Jan 13 17:44:29 2010 +0100
+++ b/web/data/cubicweb.edition.js Thu Jan 14 11:12:52 2010 +0100
@@ -328,15 +328,22 @@
for (fieldname in errors) {
var errmsg = errors[fieldname];
var fieldid = fieldname + ':' + eid;
- var field = jqNode(fieldname + ':' + eid);
- if (field && getNodeAttribute(field, 'type') != 'hidden') {
- if ( !firsterrfield ) {
- firsterrfield = 'err-' + fieldid;
+ var suffixes = ['', '-subject', '-object'];
+ var found = false;
+ for (var i=0, length=suffixes.length; i<length;i++) {
+ var field = jqNode(fieldname + suffixes[i] + ':' + eid);
+ if (field && getNodeAttribute(field, 'type') != 'hidden') {
+ if ( !firsterrfield ) {
+ firsterrfield = 'err-' + fieldid;
+ }
+ addElementClass(field, 'error');
+ var span = SPAN({'id': 'err-' + fieldid, 'class': "error"}, errmsg);
+ field.before(span);
+ found = true;
+ break;
}
- addElementClass(field, 'error');
- var span = SPAN({'id': 'err-' + fieldid, 'class': "error"}, errmsg);
- field.before(span);
- } else {
+ }
+ if (!found) {
firsterrfield = formid;
globalerrors.push(_(fieldname) + ' : ' + errmsg);
}