You are here

function profile2_form_field_ui_field_edit_form_alter in Profile 2 7

Same name and namespace in other branches
  1. 7.2 profile2.module \profile2_form_field_ui_field_edit_form_alter()

Implements hook_form_FORMID_alter().

Adds a checkbox for controlling field view access to fields added to profiles.

File

./profile2.module, line 1099
Support for configurable user profiles.

Code

function profile2_form_field_ui_field_edit_form_alter(&$form, &$form_state) {
  if (!empty($form['instance']['entity_type']['#value']) && $form['instance']['entity_type']['#value'] == 'profile2') {
    $form['field']['settings']['profile2_private'] = array(
      '#type' => 'checkbox',
      '#title' => t('Make the content of this field private.'),
      '#default_value' => !empty($form['#field']['settings']['profile2_private']),
      '#description' => t('If checked, the content of this field is only shown to the profile owner and administrators.'),
    );
  }
  else {

    // Add the value to the form so it isn't lost.
    $form['field']['settings']['profile2_private'] = array(
      '#type' => 'value',
      '#value' => !empty($form['#field']['settings']['profile2_private']),
    );
  }
}