You are here

function user_relationship_invites_form_invite_form_alter in User Relationships 7

Implements hook_form_alter().

File

user_relationship_invites/user_relationship_invites.module, line 33
Drupal Module: User Relationship Invites

Code

function user_relationship_invites_form_invite_form_alter(&$form, $form_state) {
  global $user;
  $new_user = drupal_anonymous_user();

  // Allow all user relationships for this user. Permission checks will be done
  // later.
  $new_user->user_relationships_allow_all = TRUE;
  module_load_include('inc', 'user_relationships_ui', 'user_relationships_ui.forms');
  $form += user_relationships_ui_request_form($user, $new_user, isset($form_state['values']) ? $form_state['values'] : array());
  if (isset($form['rtid'])) {
    $form['ur_request'] = array(
      '#type' => 'checkbox',
      '#title' => t('Request relationship'),
      '#weight' => -1,
      '#default_value' => 1,
    );
    $form['rtid']['#weight'] = 0;

    // Only show rtid if ur_request is checked.
    $form['rtid']['#states'] = array(
      'visible' => array(
        ':input[name=ur_request]' => array(
          'checked' => TRUE,
        ),
      ),
    );
    $form['#validate'][] = 'user_relationship_invites_invite_form_validate';
  }
}