function feedback_form in Feedback 7.2
Same name and namespace in other branches
- 5.2 feedback.module \feedback_form()
- 6.2 feedback.module \feedback_form()
Form constructor for the feedback form.
See also
1 string reference to 'feedback_form'
- feedback_page_build in ./
feedback.module - Implements hook_page_build().
File
- ./
feedback.module, line 337 - Allows site visitors and users to report issues about this site.
Code
function feedback_form($form, &$form_state) {
$form['#attributes']['class'] = array(
'feedback-form',
);
// Store the path on which this form is displayed.
if (!isset($form_state['inline']['location'])) {
$form_state['inline']['location'] = $_GET['q'];
}
$form['location'] = array(
'#type' => 'value',
'#value' => $form_state['inline']['location'],
);
$help = variable_get('feedback_help', 'If you experience a bug or would like to see an addition on the current page, feel free to leave us a message.');
$form['help'] = array(
'#prefix' => '<div class="feedback-help">',
'#markup' => t($help),
'#suffix' => '</div>',
);
if (user_access('view feedback messages')) {
if (arg(0) != 'node') {
$feedbacks = feedback_load_multiple(array(), array(
'status' => FEEDBACK_OPEN,
'location_masked' => feedback_mask_path($_GET['q']),
));
}
else {
$feedbacks = feedback_load_multiple(array(), array(
'status' => FEEDBACK_OPEN,
'location' => $_GET['q'],
));
}
if ($feedbacks) {
form_load_include($form_state, 'inc', 'feedback', 'feedback.admin');
$form['messages'] = array(
'#prefix' => '<div class="feedback-messages">',
'#suffix' => '</div>',
);
foreach ($feedbacks as $fid => $feedback) {
$form['messages'][$fid] = array(
'#type' => 'container',
'#attributes' => array(
'class' => array(
'feedback-entry',
),
),
'#feedback' => $feedback,
);
$form['messages'][$fid]['submitted'] = array(
'#markup' => t('@feedback-author !feedback-date:', array(
'@feedback-author' => format_username($feedback),
'!feedback-date' => format_date($feedback->timestamp, 'small'),
)),
);
$form['messages'][$fid]['submitted']['#prefix'] = '<div class="feedback-submitted">';
$form['messages'][$fid]['submitted']['#suffix'] = '</div>';
feedback_build_content($feedback, 'widget');
$form['messages'][$fid]['body'] = $feedback->content;
unset($feedback->content);
$form['messages'][$fid]['body']['#prefix'] = '<div class="feedback-body">';
$form['messages'][$fid]['body']['#suffix'] = '</div>';
}
}
}
$message = variable_get('feedback_message', 'Message');
$form['message'] = array(
'#type' => 'textarea',
'#attributes' => array(
'class' => array(
'feedback-message',
),
),
'#cols' => 20,
'#title' => t($message),
'#required' => TRUE,
'#wysiwyg' => FALSE,
);
$entry = new stdClass();
field_attach_form('feedback', $entry, $form, $form_state);
$form['actions'] = array(
'#type' => 'actions',
// Without clearfix, the AJAX throbber wraps in an ugly way.
// @todo Patch #type actions in core?
'#attributes' => array(
'class' => array(
'clearfix',
),
),
);
$submit = variable_get('feedback_submit', 'Send feedback');
$form['actions']['submit'] = array(
'#type' => 'submit',
'#value' => t($submit),
'#id' => 'feedback-submit',
'#ajax' => array(
'wrapper' => 'feedback-form',
'callback' => 'feedback_form_ajax_callback',
'progress' => array(
'type' => 'throbber',
'message' => '',
),
),
);
return $form;
}