You are here

function fb_example_form_alter in Drupal for Facebook 6.3

Same name and namespace in other branches
  1. 7.3 contrib/fb_example.module \fb_example_form_alter()

Implements hook_form_alter().

Adds a checkbox to node edit and comment forms. This checkbox lets facebook users know that content may be published to their Wall, and gives them a chance to prevent that.

File

contrib/fb_example.module, line 41
Example customizations to modules/fb.

Code

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

  // Add stream publish option.
  if (isset($GLOBALS['_fb']) && fb_facebook_user() && variable_get('fb_example_stream_form_alter', TRUE)) {
    if ($form['#id'] == 'node-form') {

      // Add checkbox to control feed publish.
      $form['fb_example']['stream_publish'] = array(
        '#type' => 'checkbox',
        '#title' => t('Share on Facebook Wall'),
        '#default_value' => variable_get('fb_example_stream_publish_default', FALSE),
      );
    }
    elseif ($form['form_id']['#value'] == 'comment_form') {

      // Add checkbox to control feed publish.
      $form['fb_example']['stream_publish'] = array(
        '#type' => 'checkbox',
        '#title' => t('Share on Facebook Wall'),
        '#default_value' => variable_get('fb_example_stream_publish_default', FALSE),
      );
    }
  }
}