The role of magnetic fields for planetary formation