The way the codes currently work is that, when adding a new tree, a method in the Plot collection would get the plot number and the site name from the first Tree model in the collection. However, this would not work in a new, empty plot, since the add-new-tree method in the Plot collection would not be able to find any Tree model to get the site name and the plot number from.
There are two ways to fix this.
One is to get the site name and the plot number from the hidden fields in the header—like a part of the codes currently does for a different purpose.
Two is to define in the Plot collection the site name and the plot number. This makes more sense, but it is not necessary and can be more troublesome.
The way the codes currently work is that, when adding a new tree, a method in the Plot collection would get the plot number and the site name from the first Tree model in the collection. However, this would not work in a new, empty plot, since the add-new-tree method in the Plot collection would not be able to find any Tree model to get the site name and the plot number from.
There are two ways to fix this.
One is to get the site name and the plot number from the hidden fields in the header—like a part of the codes currently does for a different purpose.
Two is to define in the Plot collection the site name and the plot number. This makes more sense, but it is not necessary and can be more troublesome.