overides required with optional.
This commit is contained in:
Adam Young 2011-06-27 15:57:40 -04:00
parent d2d5278c52
commit 6e967d8fe7
3 changed files with 12 additions and 2 deletions

View File

@ -116,6 +116,10 @@ IPA.add_dialog = function (spec) {
var fields = that.fields.values;
for (var i=0; i<fields.length; i++) {
fields[i].validate();
}
for (i=0; i<fields.length; i++) {
field = fields[i];
if (!field.valid) return;

View File

@ -344,8 +344,6 @@ IPA.dialog = function(spec) {
var factory = field_spec.factory || IPA.text_widget;
field = factory(field_spec);
field.optional = field_spec.optional || false;
/* This is a bit of a hack, and is here to support ACI
permissions. The target section is a group of several
widgets together. It makes more sense to do them as a

View File

@ -39,6 +39,8 @@ IPA.widget = function(spec) {
that.disabled = spec.disabled;
that.hidden = spec.hidden;
that.conditional = spec.conditional;
that.optional = spec.optional || false;
// read_only is set during initialization
that.read_only = spec.read_only;
@ -79,6 +81,12 @@ IPA.widget = function(spec) {
var values = that.save();
if (!values || !values.length) {
if (that.param_info &&
that.param_info.required &&
!that.optional) {
that.valid = false;
that.show_error('required field');
}
return;
}