Breast fed baby

My 2 week old gets so frustrated when I try to breastfeed him. This just started last night and had continued through today. He just cries and moves his head back and forth and won't latch... then he will latch for a second and let go and cry.. and he just won't do it so I had to give him formula all day today.. why would he be doing this? He took the bottles fine. I did have something to eat yestorday that he onions in it and I heard that it flavors your milk like them. Is that true lol? I just don't know why he is getting so mad at the breast but takes his bottle fine. Help please