You are here

function hook_domain_conf in Domain Access 7.3

Allows modules to add additional form elements for saving as domain-specific settings. Note that this is a "convenience function" to use in place of hook_form_alter(), so you may use either. Versions prior to 7.x.3 are not complete replacements for hook_form_alter().

When naming your form arrays, remember that the final key is the name of the variable that you wish to alter. The example below changes the default user picture depending on the active domain.

Preferred use is to wrap your form elements in a named fieldset, for easier viewing.

This hook is implemented by the Domain Conf module.

You may wish to pair this hook with hook_domain_batch() to allow the mass update of your settings.

If you wish to store settings that are not related to another module, you must pass the following parameter:

$form['myform']['#domain_setting'] = TRUE;

Doing so will tell Domain Access that no default settings page exists, and that values must be stored for the primary domain. This feature is useful for creating special data that needs to be associated with a domain record but does not need a separate table.

Using the variable override of hook_domain_conf() is an alternative to creating a module and database table for use with hook_domain_load().

NOTE: The responding module is required to check that the user has access to this form setting. Failure to check access on the form elements may introduce a security risk.

Return value

A $form array element as defined by the FormsAPI.

Related topics

2 invocations of hook_domain_conf()
domain_conf_api in domain_conf/domain_conf.module
Retrieves elements from hook_domain_conf() and formats them as needed.
domain_settings_reset in domain_settings/domain_settings.module
Erase Domain Conf and Batch settings but keep those set by this module.

File

./domain.api.php, line 338
API documentation file.

Code

function hook_domain_conf() {
  $form['pictures'] = array(
    '#type' => 'fieldset',
    '#title' => t('User picture'),
    '#collapsible' => TRUE,
    '#collapsed' => FALSE,
  );
  $form['pictures']['user_picture_default'] = array(
    '#type' => 'textfield',
    '#title' => t('Default picture'),
    '#default_value' => variable_get('user_picture_default', ''),
    '#size' => 30,
    '#maxlength' => 255,
    '#description' => t('URL of picture to display for users with no custom picture selected. Leave blank for none.'),
  );
  return $form;
}