Dynamic Picklist clears data when editting

Dynamic Picklist clears data when editting

I have a dynamic picklist setup using the tutorial provided in the FAQ and populates a drop-down based on the input from the previous drop-down.  But, when I edit an entry it seems I lose the data...seems to reset.  I assume I have to add code to the "on update" script area for my field...but am not sure how to set it up.  Here's my "On User Input" script:

if (count(Add_Teacher[School == input.School])  ==  0)
{
    clear Teacher;
}
else
{
    Teacherlist  =  Add_Teacher  [School == input.School] sort by  Teacher ;
    Teacher:ui.add(Teacherlist.Teacher.getall());
}