I have a home in Missouri that the very same thing was done. It is in a area with no codes. I don't know if I could get away with that were my primary home is (northern IL)! Codes and restrictions vary tremendously depending on what area you are in. States counties cites all have restrictions. The panel should be safe mounting it inside a cabinet as long as the front panel is on however they may have rules and restrictions against it depending on your location.