Theming forms is a little different than working with the usual template file or theme function. Form markup is generated using Drupal’s Form API. This makes it really easy for modules to build forms and guarantees consistency among generated elements. While the process of theming forms is quite different from what most front-end developers are used to, we think you’ll begin to appreciate the consistency and flexibility of theming Drupal’s forms.
One thing Drupal is famous for is the ability to accomplish a single task in many different ways. Although none of Drupal’s forms ship with template files, they can easily be made to use them. Forms can also use preprocess functions, process functions, and alter hooks. So, how do you know when to use one over the other? This section will explain how forms are generated and will present a couple of examples using each method.