You are here

function ajax_comments_edit in AJAX Comments 7

Callback for clicking "edit".

1 string reference to 'ajax_comments_edit'
ajax_comments_menu in ./ajax_comments.module
Implements hook_menu().

File

./ajax_comments.module, line 684
AJAX comments module file.

Code

function ajax_comments_edit($comment) {
  $node = node_load($comment->nid);

  // Build form.
  $form_build = drupal_get_form("comment_node_{$node->type}_form", $comment);
  $form = drupal_render($form_build);

  // Remove anchor
  $commands[] = ajax_command_remove('a#comment-' . $comment->cid);

  // Replace comment with form.
  $commands[] = ajax_command_replace('.comment-wrapper-' . $comment->cid, $form);
  if (!variable_get('ajax_comments_disable_scroll', 0)) {
    $commands[] = array(
      'command' => 'ajaxCommentsScrollToElement',
      'selector' => '.ajax-comments-reply-form-' . $comment->nid . '-' . $comment->pid . '-' . $comment->cid,
    );
  }
  return array(
    '#type' => 'ajax',
    '#commands' => $commands,
  );
}