Automatic form generation from template