I did a google search and the same thing kept cropping up, lack of water may cause the sets to bolt. They also said snap the flower stem off. I believe onions are very shallow rooting, so weeding is a problem....have you weeded and perhaps damaged the roots, therefore stressing the plant out and causing it to go to seed? I remember there is another posting about onions going to seed, and I understand that they are still edible, but they don't store as well. :-\