Use JForm.
This removes a bunch of logic from the templates and makes easier to extend the form through plugins.