Fixed setting of checkbox and date inputs when a form is preloaded

Involved splitting off some of formHTML() into a separate function - a
small step in the right direction.

Change-Id: I557670cef03c65817eeb41c4543621a7e89b3c26