My question is do I need the else that adds the hidden element. I had assumed that without it the data in the database would be removed.
I'm not a moodleform's expert by any means, but a fast read of the code makes me think your assumption is right.
Saludos. Iñaki.