Fix default value selection in radio widget https://fedorahosted.org/freeipa/ticket/3718 -- Petr Vobornik
From 9df5d05592e247b9d082377c0c309efbc5e1f74d Mon Sep 17 00:00:00 2001 From: Petr Vobornik <pvobo...@redhat.com> Date: Tue, 18 Jun 2013 18:11:04 +0200 Subject: [PATCH] Fix default value selection in radio widget
https://fedorahosted.org/freeipa/ticket/3718 --- install/ui/src/freeipa/widget.js | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/install/ui/src/freeipa/widget.js b/install/ui/src/freeipa/widget.js index 0913914d5af158c8e94e841583077b1dfe4166c1..ac93b91d6960de127ba0e6b71a6efbe81771a59f 100644 --- a/install/ui/src/freeipa/widget.js +++ b/install/ui/src/freeipa/widget.js @@ -666,6 +666,7 @@ IPA.option_widget_base = function(spec, that) { that.value_changed = that.value_changed || IPA.observer(); that.updated = that.updated || IPA.observer(); that.default_value = spec.default_value || null; + that.default_on_empty = spec.default_on_empty === undefined ? true : spec.default_on_empty; /** * Jquery reference to current node @@ -959,9 +960,18 @@ IPA.option_widget_base = function(spec, that) { if (values && values.length > 0) { + + if (that.default_on_empty && that.default_value !== null) { + for (var i=0; i<values.length; i++) { + if (values[i] === '') { + values[i] = that.default_value; + } + } + } + // check the option when option or some of its child should be // checked - for (var i=0; i<that.options.length; i++) { + for (i=0; i<that.options.length; i++) { var option = that.options[i]; var opt_vals = that.get_values(option); var has_opt = array.some(values, function(val) { -- 1.8.1.4
_______________________________________________ Freeipa-devel mailing list Freeipa-devel@redhat.com https://www.redhat.com/mailman/listinfo/freeipa-devel