Skip to content

Commit f3ac857

Browse files
author
riot
committed
Fix for objects with nameProperty == "name"
I used this for objects, where the name field is already called "name" - not sure if it serves well for all cases, as is.
1 parent c310a4c commit f3ac857

File tree

1 file changed

+15
-13
lines changed

1 file changed

+15
-13
lines changed

src/angular-schema-form-dynamic-select.js

Lines changed: 15 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -180,20 +180,22 @@ angular.module('schemaForm').controller('dynamicSelectController', ['$scope', '$
180180
separator = newOptions.map.separatorValue ? newOptions.map.separatorValue : ' - ';
181181
data.forEach(function (current_row) {
182182
current_row["value"] = current_row[newOptions.map.valueProperty];
183-
current_row["name"] = ""; //init the 'name' property
184-
//check if the value passed is a string or not
185-
if (typeof newOptions.map.nameProperty != 'string') {
186-
//loop through the object/array
187-
for (var i in newOptions.map.nameProperty) {
188-
current_row["name"] += current_row[newOptions.map.nameProperty[i]];
189-
if (i != final) {
190-
current_row["name"] += separator
191-
};
183+
if (newOptions.map.nameProperty !== "name") {
184+
current_row["name"] = ""; //init the 'name' property
185+
//check if the value passed is a string or not
186+
if (typeof newOptions.map.nameProperty != 'string') {
187+
//loop through the object/array
188+
for (var i in newOptions.map.nameProperty) {
189+
current_row["name"] += current_row[newOptions.map.nameProperty[i]];
190+
if (i != final) {
191+
current_row["name"] += separator
192+
};
193+
}
194+
}
195+
else {
196+
//if it is a string
197+
current_row["name"] = current_row[newOptions.map.nameProperty];
192198
}
193-
}
194-
else {
195-
//if it is a string
196-
current_row["name"] = current_row[newOptions.map.nameProperty];
197199
}
198200
form.titleMap.push(current_row);
199201
});

0 commit comments

Comments
 (0)