I am trying to update a node with a standard multi value text field programatically with the following:
$node = customfunctionreturnsnode();
$node->field_scores['und'][$dayof]['value'] = $total;
node_save($node);
More info: $dayof
is a custom variable, that can be from 1 - 28. $total
is numerical value that is determined elsewhere in the code.
Eventually the field will have 28 values, but they might not get entered in the 'correct' order. So I would like to be able to have my code above select which delta to add it to. Also, the values could get updated, so this will allow me to update the correct value.
It seems to work, and the db shows the right delta. But when I add a new value the previous delta resets to 0. The new delta has the correct value, but when I add another one the second value's delta goes to 1... and so on.
I checked, and the delta field is not an auto-increment table... but I'm not really sure where to look from here. I couldn't find anyone else that has this issue. Am I doing something wrong?
Thank you for you time.