Locked fields empty after save

When a field is set to be locked or hidden it'll be empty after saving the page. This only happens when you set te visibility of the field via the template. When setting the visibility on the field itself, it works just fine. Only happens in 2.5, not in 2.4.