You are here

function commerce_form_callback in Commerce Core 7

Returns the callback for a form ID as defined by hook_forms().

Parameters

$form_id: The form ID to find the callback for.

Return value

A string containing the form's callback function name.

See also

drupal_retrieve_form()

hook_forms()

File

./commerce.module, line 319
Defines features and functions common to the Commerce modules.

Code

function commerce_form_callback($form_id, $form_state) {

  // If a function named after the $form_id does not exist, look for its
  // definition in hook_forms().
  if (!function_exists($form_id)) {
    $forms =& drupal_static(__FUNCTION__);

    // In cases where many form_ids need to share a central builder function,
    // such as the product editing form, modules can implement hook_forms(). It
    // maps one or more form_ids to the correct constructor functions.
    if (!isset($forms) || !isset($forms[$form_id])) {
      $forms = module_invoke_all('forms', $form_id, $form_state['build_info']['args']);
    }
    if (isset($forms[$form_id]['callback'])) {
      return $forms[$form_id]['callback'];
    }
  }
  return $form_id;
}