You are here

function profile2_page_form_profile2_type_form_alter in Profile 2 7

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

Implements hook_form_FORM_ID_alter() for the profile2 type form..

File

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

Code

function profile2_page_form_profile2_type_form_alter(&$form, &$form_state) {
  $type = $form_state['profile2_type'];
  $form['data']['use_page'] = array(
    '#type' => 'checkbox',
    '#title' => t('Provide a separate page for editing profiles.'),
    '#description' => t('If enabled, a separate menu item for viewing and editing the profile is generated, and the profile is hidden from the user account page.'),
    '#default_value' => empty($type->is_new) && !empty($type->data['use_page']),
    '#states' => array(
      'invisible' => array(
        ':input[name="data[use_tab]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['data']['edit_label'] = array(
    '#type' => 'checkbox',
    '#title' => t('Allow the profile title to be edited.'),
    '#description' => t('If enabled, the title of the profile is editable, and is used as-is when displaying the profile.'),
    '#default_value' => empty($type->is_new) && !empty($type->data['edit_label']),
    '#states' => array(
      'invisible' => array(
        ':input[name="data[use_page]"]' => array(
          'checked' => FALSE,
        ),
      ),
    ),
  );
  $form['data']['use_tab'] = array(
    '#type' => 'checkbox',
    '#title' => t('Provide a separate tab for viewing profiles.'),
    '#description' => t('If enabled, the profile is shown under a separate tab on the user account page.'),
    '#default_value' => empty($type->is_new) && !empty($type->data['use_tab']),
    '#states' => array(
      'invisible' => array(
        ':input[name="data[use_page]"]' => array(
          'checked' => TRUE,
        ),
      ),
    ),
  );
  $form['data']['#tree'] = TRUE;
  $form['#validate'][] = 'profile2_page_form_profile2_type_form_validate';
}