I did that for my wedding cake, and we used wires. It may have been jewelry wire.. I can't remember..
It was thin enough to poke through the flowers, and stick in the cake without leaving any big gaping holes. We just made sure when it was time for cake, that if a flower came out without a wire, it would need to be removed. Which, in that case, if the flower slipped off, then the wire would be visibly poking out of the cake.
I'm sure there are better ways to do it, but this worked well for us.