Commit fdfaf635 authored by Rafael Ostertag's avatar Rafael Ostertag
Browse files

QfqForm.js: QfqForm#applyElementConfiguration() now expects array of objects.

parent 562a1171
......@@ -459,26 +459,32 @@ if (!QfqNS) {
);
};
/**
*
* @param configuration {array} array of objects.
*/
n.QfqForm.prototype.applyElementConfiguration = function (configuration) {
// key is the name attribute of the Form control.
for (var key in configuration) {
if (!configuration.hasOwnProperty(key)) continue;
var arrayLength = configuration.length;
for (var i = 0; i < arrayLength; i++) {
var configurationItem = configuration[i];
var formElementName = configurationItem["form-element"];
if (formElementName === undefined) {
QfqNS.Log.error("configuration lacks 'form-element' attribute. Skipping.");
continue;
}
try {
var element = n.Element.getElement(key);
var formControlConfig = configuration[key];
var element = n.Element.getElement(formElementName);
if (formControlConfig.value !== undefined) {
element.setValue(formControlConfig.value);
if (configurationItem.value !== undefined) {
element.setValue(configurationItem.value);
}
if (formControlConfig.readonly !== undefined) {
element.setReadOnly(formControlConfig.readonly);
if (configurationItem.readonly !== undefined) {
element.setReadOnly(configurationItem.readonly);
}
if (formControlConfig.disabled !== undefined) {
element.setEnabled(!formControlConfig.disabled);
if (configurationItem.disabled !== undefined) {
element.setEnabled(!configurationItem.disabled);
}
} catch (e) {
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment