Refactor form input helpers to remove duplication