Remove duplicate code
add flexibility for select form generator.