You are here

function fb_connect_form_alter in Drupal for Facebook 7.3

Same name and namespace in other branches
  1. 5.2 fb_connect.module \fb_connect_form_alter()
  2. 6.3 fb_connect.module \fb_connect_form_alter()
  3. 6.2 fb_connect.module \fb_connect_form_alter()

Implements hook_form_alter().

File

./fb_connect.module, line 350
Support for Facebook Connect features

Code

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

  // Add our settings to the fb_app edit form.
  if (isset($form['fb_app_data'])) {
    $fb_app = $form['#fb_app'];
    $form['fb_app_data']['fb_connect'] = array(
      '#type' => 'fieldset',
      '#title' => 'Facebook connect',
      '#tree' => TRUE,
      '#collapsible' => TRUE,
      '#collapsed' => $fb_app->label ? TRUE : FALSE,
    );

    // "Primary" will be initialized on every non-canvas page.
    $primary_label = variable_get(FB_CONNECT_VAR_PRIMARY, NULL);
    $form['fb_app_data']['fb_connect']['primary'] = array(
      '#type' => 'checkbox',
      '#title' => t('Primary'),
      '#description' => t('Initialize fbConnect javascript on all (non-canvas) pages.  If this site supports multiple Facebook Apps, this may be checked for at most one.'),
      '#default_value' => isset($fb_app->label) && $primary_label == $fb_app->label,
    );
    if ($primary_label && $primary_label != $fb_app->label) {
      $form['fb_app_data']['fb_connect']['primary']['#description'] .= '<br/>' . t('Note that checking this will replace %app as the primary Facebook Connect app.', array(
        '%app' => $primary_label,
      ));
    }
    $form['buttons']['submit']['#submit'][] = 'fb_connect_app_submit';
  }
}