Magnetic fields in giant planet formation and protoplanetary discs