Role of magnetic fields in the birth of a young star traced