views:

42

answers:

1

I want to override a bit of core drupal behavior on the comment form.

If you make a comment as an anonymous user, your name and mail are stored in a cookie, and then javascript fills out the appropriate fields in subsequent comment forms using this code below:

Drupal.behaviors.comment = function (context) {
  var parts = new Array("name", "homepage", "mail");
  var cookie = '';
  for (i=0;i<3;i++) {
    cookie = Drupal.comment.getCookie('comment_info_' + parts[i]);
    if (cookie != '') {
      $("#comment-form input[name=" + parts[i] + "]:not(.comment-processed)", context)
        .val(cookie)
        .addClass('comment-processed');
    }
  }
};

If I don't want those fields to be filled in, I know I can just wipe out the information with further javascript, but I'm sure there's a 'cleaner' way to do it.

+1  A: 

If you have a custom module, you should be able to overwrite Drupal.behavious.comment, or delete it.

something like

drupal_add_js('delete Drupal.behavious.comment','inline');

Of course if you already have a js file being included put it there rather than inline.

Jeremy French
Thanks Jeremy, the inline version works. I think comment.js has already been executed by the time I delete it in a custom .js file.
lazysoundsystem