Modifying Forms in Drupal 5 and 6

Modifying Forms in Drupal 5 and 6


Add Comment
Share
Source Articles
17
Monday, March 17, 2008
By admin
Drupal has a lot of forms to fill out and not all of them may be just the way you want or need them to be. Modifying forms is a topic that is often met with groans but once you understand the two methods to accomplish the task and the basic, underlying concepts, it really isn’t that hard to do at all. You’ll be a form-modifying, input-customizing wiz in no time. This article will briefly discuss what’s going on and then mainly focus on showing working examples for both methods in Drupal 5 and 6. You should be comfortable creating a new function, looking at arrays and a having at least a passing understanding of the Forms API is real handy. Also note that in the examples below I have them wrapped in php tags but you should not include those if you copy/paste. That is just so it looks nice and clear for the article.

Deciding to make the change in the theme or a module
So there are two methods for altering form output in Drupal, one at the theme layer and the other through a custom module. Changes to the HTML can be accomplished with either method so most people will use the method they are more comfortable with already; themers use the theme and developers use a module. There are two situations however where you will want to use a module rather than a theme:

Changing functionality of a form (e.g. adding new validation rules or submission actions) can only happen in a module.
read more

Leave a Reply

Your email address will not be published. Required fields are marked *