Skip to content
This repository has been archived by the owner on Dec 21, 2021. It is now read-only.

Commit

Permalink
AUI-1034 Predefined value is lost when radio option value is changed
Browse files Browse the repository at this point in the history
  • Loading branch information
marcellustavares authored and eduardolundgren committed Nov 20, 2013
1 parent bb627fb commit 3f509d9
Showing 1 changed file with 14 additions and 4 deletions.
18 changes: 14 additions & 4 deletions src/aui-form-builder/js/aui-form-builder-field-radio.js
Expand Up @@ -152,13 +152,21 @@ var FormBuilderRadioField = A.Component.create({
var instance = this,
buffer = [],
counter = 0,
hasPredefinedValue = false,
predefinedValue = instance.get(PREDEFINED_VALUE),
templateNode = instance.get(TEMPLATE_NODE);

A.each(val, function(item, index, collection) {
var index = A.Array.indexOf(predefinedValue, item.value);

if (index != -1) {
hasPredefinedValue = true;
}

buffer.push(
L.sub(
TPL_RADIO, {
checked: item.value === instance.get(PREDEFINED_VALUE) ? 'checked="checked"' : EMPTY_STR,
checked: (index != -1) ? 'checked="checked"' : EMPTY_STR,
disabled: instance.get(DISABLED) ? 'disabled="disabled"' : EMPTY_STR,
id: instance.get(ID) + counter++,
label: item.label,
Expand All @@ -173,9 +181,11 @@ var FormBuilderRadioField = A.Component.create({

templateNode.setContent(instance.optionNodes);

instance._uiSetPredefinedValue(
instance.get(PREDEFINED_VALUE)
);
if (!hasPredefinedValue) {
instance.set(PREDEFINED_VALUE, instance._valuePredefinedValueFn());

instance.get('builder').editField(instance);
}
},

/**
Expand Down

0 comments on commit 3f509d9

Please sign in to comment.