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
Comment #1
killes@www.drop.org commentedI'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.
Comment #2
moshe weitzman commentedOK ... We need Zen to port comment to fapi. I will ask him if he plans to work on. It is a non trivial task.
Comment #3
moshe weitzman commentedkilles - 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.
Comment #4
sanjeev gupta commentedComment #5
killes@www.drop.org commentedthanks to the removal of this crufty code this feature will work with a future Drupal 4.7.1.
Comment #6
moshe weitzman commentedkilles - i think we still need to unset the #required in the comment body using casetracker_form_alter()
Comment #7
sanjeev gupta commentedFixed & Committted to CVS.
Comment #8
(not verified) commentedComment #9
nicholas.alipaz commentedI 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.
Comment #10
Grayside commentedHere's your snippet:
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).Comment #11
nicholas.alipaz commentedGrayside, 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.
Comment #12
jmiccolis commentedThis 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.