I use these:Yes sir that is the way to do it.
I saw recently a guy used the type of magnets that cabinets have. Although they are a little larger and not great looking they would work great for this sort of application.
View attachment 183434
https://www.aliexpress.com/item/4001042144647.html?spm=a2g0s.9042311.0.0.475f4c4dNeQplG