/**
 * Implements hook_form_FORM_ID_alter().
 */
function mymodule_form_honeypot_admin_form_alter(&$form, &$form_state, $form_id) {
  $form['enabled_forms']['mymodule'] = array('#markup' => '<h5>' . t('Mymodule Forms') . '</h5>');
  $form['enabled_forms']['honeypot_form_mymodule_special_form'] = array(
    '#type' => 'checkbox',
    '#title' => t('Mymodule special form'),
    '#default_value' => variable_get('honeypot_form_mymodule_special_form', 0),
  );
}

This is what I did ^, and it works great. The question is, will it work in the future? I think it would be better to register custom forms with a new hook, something like:

/**
 * Implements hook_honeypot_register_custom_forms();
 */
function mymodule_honeypot_register_custom_forms() {
  $forms = array(
    'mymodule_registration_form' => array(
      'title' => t('Mymodule registration form'),
      'category' => t('Mymodule Forms'),
    ),
    'mymodule_contact_form' => array(
      'title' => t('Mymodule contact form'),
      'category' => t('Mymodule Forms'),
    ),
  );
  return $forms;
}

Comments

geerlingguy’s picture

Title: New hook to add custom forms to settings page » New hook for adding forms to settings page

Your current solution should work great for the foreseeable future, as that form won't be changed unless there's a new major version. Having a hook for adding forms to the defaults on the settings array is a good idea, but I'll have to think about how I'd want that to work before committing to anything.

If I had a good API for this, I could make a secondary module like honeypot_extra_forms that adds in webforms, comment forms, etc. That would keep the main Honeypot module a bit cleaner as well.

geerlingguy’s picture

geerlingguy’s picture

Issue summary: View changes
Status: Active » Closed (won't fix)

I think, for now, I'm going to close this issue and put support behind #2342473: Allow for more flexible form configuration, which would allow any form to be added simply by pasting in the form ID. That method is a lot more flexible in general, and wouldn't rely on extra 3rd party module support (or a separate 'Honeypot Extras' module or something like that).