You are here

function profile2_diff_form_profile2_form_alter in Profile 2 7.2

Implements hook_form_alter().

Add View Changes button to profile edit form.

File

contrib/profile2_diff.module, line 171
Provides functionality to show a diff between two profile2 revisions.

Code

function profile2_diff_form_profile2_form_alter(&$form, $form_state, $form_id) {

  // Only one profile is expected, but this gets the key and value.
  foreach ($form_state['profiles'] as $type => $profile) {
    if (!empty(profile2_get_types($type)->data['preview_changes']) && $profile->pid > 0 && user_access('diff view changes')) {
      $form['actions']['preview_changes'] = array(
        '#type' => 'submit',
        '#value' => t('View changes'),
        '#weight' => 40,
        '#submit' => array(
          'profile2_diff_profile2_form_preview_changes',
        ),
      );
    }

    // If content for changes has been added to the form_state,
    // display using the form #prefix.
    if (isset($form_state['profile_preview'])) {
      $form['#prefix'] = $form_state['profile_preview'];
    }
  }
}