You are here

function profile2_page_forms in Profile 2 7

Same name and namespace in other branches
  1. 7.2 contrib/profile2_page.module \profile2_page_forms()

Implements hook_forms().

File

contrib/profile2_page.module, line 192
Adds separate pages for viewing and editing profiles.

Code

function profile2_page_forms($form_id, $args) {

  // For efficiency, only act if the third argument is 'profile2'.
  if (isset($args[2]) && is_string($args[2]) && $args[2] == 'profile2') {
    $info = entity_get_info('profile2');

    // Translate bundle form ids to the base form id 'profile2_form'.
    foreach ($info['bundles'] as $bundle => $bundle_info) {
      $forms['profile2_edit_' . $bundle . '_form']['callback'] = 'profile2_form';
      $forms['profile2_edit_' . $bundle . '_form']['wrapper callback'] = 'entity_ui_form_defaults';
    }
    if (!empty($forms)) {

      // Include the file with profile2_form() callback. This needed when the
      // form is loaded from the outside, for example, from the ajax callback.
      form_load_include($form_state, 'inc', 'profile2_page');
      return $forms;
    }
  }
}