You are here

function user_relationship_elaborations_form_alter in User Relationships 6

Same name and namespace in other branches
  1. 7 user_relationship_elaborations/user_relationship_elaborations.module \user_relationship_elaborations_form_alter()

hook_form_alter() to catch the approval form

File

user_relationship_elaborations/user_relationship_elaborations.module, line 136
User Relationships Elaborations feature @author Jeff Smick (creator) @author Darren Ferguson http://drupal.org/user/70179

Code

function user_relationship_elaborations_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'user_relationships_ui_pending_requested':
      if ($form['action']['#value'] == 'approve' && !variable_get('user_relationships_elaborations_api_only', FALSE)) {
        $form['elaboration'] = array(
          '#type' => 'textarea',
          '#title' => t('Elaboration'),
          '#default_value' => $form_state['post']['elaboration'] ? $form_state['post']['elaboration'] : user_relationships_get_elaboration($form['rid']['#value']),
          '#description' => t('Please elaborate on this relationship (how/where you met, etc)'),
        );
        $form['#submit'][] = 'user_relationship_elaborations_submit';
      }
      break;
    case 'user_relationships_ui_settings':
      $form['user_relationships_elaborations'] = array(
        '#type' => 'fieldset',
        '#title' => t('Elaborations'),
        '#weight' => 0,
      );
      $form['user_relationships_elaborations']['user_relationships_elaborations_api_only'] = array(
        '#type' => 'checkbox',
        '#title' => t('Do not use the elaborations UI'),
        '#description' => t('Check this if you only need the API provided by the UR-Elaborations module'),
        '#default_value' => variable_get('user_relationships_elaborations_api_only', FALSE),
      );
      break;
    case 'user_relationships_ui_request':

      // Incase the form is an error form which the UI module has encountered
      if (!isset($form['error']) && !variable_get('user_relationships_elaborations_api_only', FALSE)) {

        // Make sure that the select box holding the relationship types is above the elaboration textarea.
        $form['rtid']['#weight'] = -10;

        // Adding text area to elaborate when creating a new relationship with another user.
        $form['elaboration'] = array(
          '#type' => 'textarea',
          '#title' => t('Elaboration'),
          '#rows' => 3,
          '#cols' => 50,
          '#description' => t('Please elaborate on this relationship (how/where you met, etc)'),
          '#weight' => -5,
        );
        $form['#submit'][] = 'user_relationship_elaborations_request_submit';
      }
      break;
  }
}