Drupal Forms API

Initial thoughts on Form API

After getting back into Drupal 5.0 development, I have spent a lot of time ranting about how I find the most recent version of Form API hard to work with. People keep asking me what is "wrong and what to do about it. So far, I have not actually been able to articulate what really bugs me, overall it is just a feeling that I am constantly fighting the API and not creating code.

Having spent some time thinking about it, I think I am starting to get an idea of what bugs me.

FAPI for Drupal 5.0

Notes, maybe some day it will be a full document.

  • Form ID = function that defines your form.
  • Form ID + _validate = validates on form submit.
  • Form ID + _submit = should save any data, called on submit if validate produces no errors.
  • theme_ + Form ID = called to theme your form.
  • Prefix/suffix (form id) for _validate/_sumbit/theme_ can be altered by adding $form['#base'] = 'new_prefix'; to the form definition.
Syndicate content