Form serialization methods

Added implementation that @haohello did in pull request #207 as a seperate pull request.