credit fields

Adding Custom Form API Elements to Drupal

In a previous entry, we took a look at modifying the date field for a custom form. In this post, we will look at how to define our own form elements inside of Drupal, with validation and processing, to use in any custom form easily.

In a previous post, we took a look at how to collect a customized date in Drupal. You may have noticed that there are warnings that the Day field are undefined, and that Drupal returns a form error saying the 'specified date is invalid'. This is because we are not passing a day part. In most cases, you would, but using the previous example again of submitting a credit card expiration date, you don't need it. So, how can we solve this problem?