Separated form element generation off into separate function.