You are here

function heartbeat_comments_form in Heartbeat 6.4

Same name and namespace in other branches
  1. 7 modules/heartbeat_comments/heartbeat_comments.module \heartbeat_comments_form()

Heartbeat comments form

1 string reference to 'heartbeat_comments_form'
heartbeat_comments_widget in modules/heartbeat_comments/heartbeat_comments.module
Implementation of <attchement>_widget().

File

modules/heartbeat_comments/heartbeat_comments.module, line 407
heartbeat_comments.module Heartbeat comments can come with two possible

Code

function heartbeat_comments_form($form_state = array(), $uaid = 0, $node_comment = FALSE, $nid = 0) {
  global $user;
  $show_form = user_access('add heartbeat comment');
  $form = array();
  if ($show_form) {
    $form['message'] = array(
      '#title' => t('React'),
      '#type' => 'textarea',
      '#required' => TRUE,
      '#rows' => 1,
      '#attributes' => array(
        'class' => 'heartbeat-message-comment',
      ),
    );

    // Get the original message from the translation table if needed.
    $form['uaid'] = array(
      '#type' => 'hidden',
      '#value' => $uaid,
      '#attributes' => array(
        'class' => 'heartbeat-message-uaid',
      ),
    );
    $form['submit'] = array(
      '#type' => 'submit',
      '#value' => t('Submit'),
      '#prefix' => '<span class="heartbeat-comments-wrapper">',
      '#suffix' => '<span class="heartbeat-messages-throbber">&nbsp;</span></span>',
      '#attributes' => array(
        'class' => 'heartbeat-comment-submit',
      ),
    );
    $form['heartbeat_comment_token'] = array(
      '#id' => 'heartbeat_comment_' . $uaid,
      '#default_value' => drupal_get_token('heartbeat_comment_' . $uaid),
      '#type' => 'hidden',
    );
    if ($nid && $node_comment) {
      $show_form = user_access('post comments');
      if ($show_form) {
        $form['node_comment'] = array(
          '#type' => 'hidden',
          '#value' => 1,
          '#attributes' => array(
            'class' => 'heartbeat-message-node-comment',
          ),
        );
        $form['nid'] = array(
          '#type' => 'hidden',
          '#value' => $nid,
          '#attributes' => array(
            'class' => 'heartbeat-message-nid',
          ),
        );
      }
    }
  }
  return $form;
}