function social_comment_form_reply_validate in Open Social 10.0.x
Same name and namespace in other branches
- 8.9 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 8 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 8.2 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 8.3 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 8.4 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 8.5 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 8.6 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 8.7 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 8.8 modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 10.3.x modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 10.1.x modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
- 10.2.x modules/social_features/social_comment/social_comment.module \social_comment_form_reply_validate()
Form validation handler for comment_form().
Validate replies to comments deeper than 1.
1 string reference to 'social_comment_form_reply_validate'
- social_comment_form_comment_form_alter in modules/
social_features/ social_comment/ social_comment.module - Implements hook_form_FORM_ID_alter().
File
- modules/
social_features/ social_comment/ social_comment.module, line 141 - The Social comment module.
Code
function social_comment_form_reply_validate($form, FormStateInterface $form_state) {
// Get parent comment ID.
if (!($pid = \Drupal::routeMatch()
->getParameter('pid'))) {
return;
}
/** @var \Drupal\comment\CommentInterface $comment */
$comment = \Drupal::entityTypeManager()
->getStorage('comment')
->load($pid);
if ($comment
->bundle() === 'post_comment') {
$form_state
->setErrorByName('', t('Replies for comments on posts are not allowed'));
}
elseif (!empty($comment
->getParentComment())) {
$form_state
->setErrorByName('', t('Replies to comments deeper than 1 is not allowed'));
}
}