You are here

function feedback_form in Feedback 6.2

Same name and namespace in other branches
  1. 5.2 feedback.module \feedback_form()
  2. 7.2 feedback.module \feedback_form()

Form builder function for a user feedback form.

1 string reference to 'feedback_form'
feedback_block in ./feedback.module
Implementation of hook_block().

File

./feedback.module, line 91
Allows site visitors and users to report issues about this site.

Code

function feedback_form() {
  $form['#attributes']['class'] = 'feedback-form';

  // Store the path on which this form is displayed.
  $form['location'] = array(
    '#type' => 'value',
    '#value' => $_GET['q'],
  );

  // Allow the form to be submitted via AJAX.
  $form['ajax'] = array(
    '#type' => 'hidden',
    '#default_value' => 0,
  );
  $form['help'] = array(
    '#prefix' => '<div class="feedback-help">',
    '#value' => t('If you experience a bug or would like to see an addition on the current page, feel free to leave us a message.'),
    '#suffix' => '</div>',
  );
  if (user_access('view feedback messages')) {
    if (arg(0) != 'node') {
      $feedbacks = feedback_load(array(
        'status' => 0,
        'location_masked' => feedback_mask_path($_GET['q']),
      ));
    }
    else {
      $feedbacks = feedback_load(array(
        'status' => 0,
        'location' => $_GET['q'],
      ));
    }
    if ($feedbacks) {
      $rows = '';
      foreach ($feedbacks as $feedback) {
        $rows .= '<div class="feedback-submitted">' . theme('username', $feedback) . ' ' . format_date($feedback->timestamp, 'small') . ':</div>';
        $rows .= '<div class="feedback-body">' . feedback_format_message($feedback) . '</div>';
      }
      $form['messages'] = array(
        '#prefix' => '<div class="feedback-messages">',
        '#value' => $rows,
        '#suffix' => '</div>',
      );
    }
  }
  $form['message'] = array(
    '#type' => 'textarea',
    '#attributes' => array(
      'class' => 'feedback-message',
    ),
    '#cols' => 20,
    '#title' => t('Message'),
    '#required' => TRUE,
    '#wysiwyg' => FALSE,
  );
  $form['submit'] = array(
    '#type' => 'submit',
    '#value' => t('Send'),
    '#id' => 'feedback-submit',
    '#prefix' => '<div id="feedback-throbber">',
    '#suffix' => '</div>',
  );
  return $form;
}