I have a module that for various reasons changes the value of the comment submit button (just a trivial text change, from 'Save' to 'Post Comment').

This causes the ajax comment submit to through an error (though the comment is still posted).

The cause of this is due to the following in ajax_comments.pages.inc
elseif ($form_state['values']['op'] == t('Save')) {

A way to do the same thing but more generically would be to use the value of $form_state['values']['submit'] since what you want to ensure is that the operation was submit. I've attached a patch that I think it should work but give more flexibility.

CommentFileSizeAuthor
ajax_comments_op_value.patch1.21 KBhadsie
Support from Acquia helps fund testing for Drupal Acquia logo

Comments

neochief’s picture

Status: Needs review » Fixed

Fixed in dev. Thanks!

GreenReaper’s picture

Status: Fixed » Needs work

Unfortunately this breaks comment preview for me. The form is submitted and some kind of response is provided by the server but no comment appears. Reverting the change fixes it (the first line changed appears to be the critical one).

neochief’s picture

Hey Laurence, could you try to solve the issue somehow (no reverting the code) and get us the patch? I guess you're closest to fix.

mattwmc’s picture

I used this mod to change my 'Save' text to 'Submit' - http://drupal.org/project/stringoverrides

Submit and Preview work fine for me.

thaddeusmt’s picture

This patch also broke the Preview functionality for me. Reversing it restored the ajax previews.

rjbrown99’s picture

Is this still an issue? It seems to be fixed in dev by a quick review of the code. I'm using this with -dev, modifying the button text in a custom module as such:

function mycustommodule_form_alter(&$form, $form_state, $form_id) {
  switch ($form_id) {
    case 'comment_form':
      // Rename button
      $form['submit']['#value'] = t('Share');
      break;
  }
}

That works fine for me and comments are submitted properly.

manderson311’s picture

Version: 6.x-1.x-dev » 6.x-1.8

I'm having the same issue with version 6.x-1-8...

I wanted the save buttons text to be blank so that I can use an image instead...

Shouldn't be doing it this way but it works for now...

Line 142 in ajax_comments.module is this

elseif ($form_state['values']['op'] == t('Save')) {

so I modified it to this

elseif ($form_state['values']['op'] == t('Save')|| $form_state['values']['op'] == t('')) {

qzmenko’s picture

Issue summary: View changes
Status: Needs work » Closed (outdated)

Issue is closed because 6.x version is unsupported. Feel free to open new issue for 7.x or 8.x versions of module.