Forms: Adding a custom element type & expanding elements

How to add custom form element types and expand elements as well.