Meteor simple schema overriding values in fields when using array


#1

I have the following simple schema :

field1: {
type : [Xschema]
}
xschema {
totalSalary: {
type: Number,
},
basicSalary: {
type: Number,
autoform: {
firstOption: false,
options: function () {
var length = _.size(AutoForm.getFieldValue(‘salaryDetails’));
var str = ‘salaryDetails.’ + (length - 1) + ‘.totalSalary’;
var salary = AutoForm.getFieldValue(str);
return {label:salary*0.6};
}
}
},
}
in the autoform when i click on the + to add more object of the xschema all the previous fields of the ‘basic salary’ get the same value for example : all basic salaries are filled with the last amount calculated

to clarify it more

total salary : 1000 -> basic salary (auto calculation) : 600

click to add +

total salary : 100 -> basic salary (auto calculation) : 60 and at the same the previous basic salary turns to be 60 as well


#2

Did you find a solution for this?