Structural phase transition in perovskite metal-formate frameworks: a Potts-type model with dipolar interactions.