refactor form generation; allow custom field templates