How to get a Drupal 7 custom form to work with Mollom

I just got a custom form in Drupal 7 to work with Mollom, and I wanted to share my source code here. I added the following code to the main module file (zenf.module) of my Drupal module:

function zenf_mollom_form_list() {
  $forms['organization_add'] = array(
    'title' => 'Form to add a new organization',
  );
  return $forms;
}

function zenf_mollom_form_info() {
  $form_info = array(
    'mode' => MOLLOM_MODE_CAPTCHA,
  );
  return $form_info;
}

This code adds the possibility of having a Mollom CAPTCHA form element on my custom form. I say "possibility" because after adding this code, you then need to configure Mollom as usual, in this case to protect my "Add a new organization" form. In Drupal 7, you configure a new form at the "/admin/config/content/mollom" URI of your website.

Drupal custom form Mollom CAPTCHA code

At this point, I just got this to work, so my code is very simple and basic. I may add more to it than this, but as shown, this code successfully adds a Mollom CAPTCHA widget to the form with the form_id "organization_add" in a custom Drupal module I've named "zenf".

As I understand it, as shown in the URL I've linked to, this is the correct way to integrate a custom Drupal form with Mollom, in this case always using the Mollom CAPTCHA approach. At least in my case, it doesn't make sense to use textual analysis, so I'm always invoking CAPTCHA.

You can see this form in action by clicking the "Add" button on the Zen Foundation Organization's List page.