add error handling in listmap, improve setting the error class in inputs and arrayinputs

This commit is contained in:
rlx 2011-10-03 23:25:38 +00:00
commit bbef38f0a9
3 changed files with 112 additions and 72 deletions

View file

@ -1,3 +1,7 @@
/*@
Ox.ArrayInput <f> Array input
@*/
Ox.ArrayInput = function(options, self) {
self = self || {};
@ -141,7 +145,6 @@ Ox.ArrayInput = function(options, self) {
self.setOption = function(key, value) {
if (key == 'value') {
Ox.print('--value--', value, self.$input)
if (self.options.value.length == 0) {
self.options.value = [''];
}
@ -156,6 +159,12 @@ Ox.ArrayInput = function(options, self) {
}
}
that.setErrors = function(values) {
self.$input.forEach(function($input) {
values.indexOf($input.value()) > -1 && $input.addClass('OxError');
});
};
// fixme: can't we generally use options.value for this?
that.value = function() {
if (arguments.length == 0) {

View file

@ -810,6 +810,7 @@ Ox.Input = function(options, self) {
self.options.value = self.options.value.toFixed(self.options.decimals);
}
self.$input.val(self.options.value);
that.is('.OxError') && that.removeClass('OxError');
setPlaceholder();
} else if (key == 'width') {
that.css({width: self.options.width + 'px'});