use form_alter hook to make comemnt body optional. sometimes you want to just change status or so. ideally, you also add a pref to not email out comments that have empty body. it is sometimes convenient to make these quiet updates and not bother the rest of the team. this is how project module works.

Comments

killes@www.drop.org’s picture

I'd like to implement this, but it won't work as the comment module still has some legacy code which has not fully been converted to form APi. In particular, comment_validate doesn't validate the form values as it should, but it uses the values of $edit. The only trick we could play would be to assign a non-printing character to the comment body in the comment validate hook. I am not too fond of the idea.

moshe weitzman’s picture

OK ... We need Zen to port comment to fapi. I will ask him if he plans to work on. It is a non trivial task.

moshe weitzman’s picture

killes - for 4.7.1 we could just remove the dead code:

// Validate the comment's body.
if (trim($edit['comment']) == '') {
form_set_error('comment', t('The body of your comment is empty.'));
}

fapi already does this check. with that code removed, we can use form_alter to remore the #required element.

what do you think? i will make a patc hand test if you like it.

sanjeev gupta’s picture

Status: Active » Fixed
killes@www.drop.org’s picture

thanks to the removal of this crufty code this feature will work with a future Drupal 4.7.1.

moshe weitzman’s picture

Status: Fixed » Active

killes - i think we still need to unset the #required in the comment body using casetracker_form_alter()

sanjeev gupta’s picture

Status: Active » Fixed

Fixed & Committted to CVS.

Anonymous’s picture

Status: Fixed » Closed (fixed)
nicholas.alipaz’s picture

Version: master » 6.x-1.0-beta6
Status: Closed (fixed) » Active

I think maybe the code for this fix was removed along the way since comments now require a description. It would be nice to have this feature back and to allow users to simply change the case settings without actually needing to supply any text to it. Much like "Anonymous" did in post #8 above.

Grayside’s picture

Here's your snippet:

function custommodule_form_comment_form_alter(&$form, &$form_state) {
  if(casetracker_is_case($form['#node'])) {
    $form['comment_filter']['comment']['#required'] = FALSE;
  }
}

Tested, it works.

Problem: You can even post comments with no text, and no changes. This means anyone that can press submit can load your database with null rows. This is bad unless it also adds a validation callback to test comment NOT NULL || (comment NULL && some state changed).

nicholas.alipaz’s picture

Grayside, thanks for the snippet. I do know how to do that however. The issue I see is that this module issue says that it added a fix to allow the comment body to be optional but it does not seem to be in the latest version of the module. Should this be added back in? I think it may have gotten lost along the way.

jmiccolis’s picture

Status: Active » Closed (fixed)

This is a nearly 4 year old ticket. You can be sure that the module has changed a great deal in that time. More over, when you updated a ticket like this you trigger notifications to the people who were interested four years ago. Setting this back to closed.

@nicholas.alipaz if you still have questions please open a new ticket.