Problem with checkbox in Settings API

I managed to figure this out. It was because on the template page where I output the form I had forgotten to include the settings_fields function, so it was not saving the setting. I added the following code below to that page and then it worked:

<?php settings_fields('prev-next-setting'); ?>