function fb_example_form_alter in Drupal for Facebook 7.3
Same name and namespace in other branches
- 6.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 20 - 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) && module_exists('fb_stream')) {
if (!empty($form['#node_edit_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['#id'] == '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),
);
}
}
}