Let the user choose the field type
Check this module:

Conditional Fields

This module lets you to set things such a visibility, depending on other form elements. 

It works based on Drupal's States API ( which you could also use in your custom module to achieve what you want )