function social_comment_form_reply_validate in Open Social 8
Same name and namespace in other branches
- 8.9 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.0.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 70 - The Social comment module.
Code
function social_comment_form_reply_validate($form, FormStateInterface $form_state) {
// Get parrent comment ID.
$pid = \Drupal::routeMatch()
->getParameter('pid');
if ($pid) {
$comment = \Drupal::entityTypeManager()
->getStorage('comment')
->load($pid);
$bundle = $comment
->bundle();
switch ($bundle) {
default:
if (!empty($comment
->getParentComment())) {
$form_state
->setErrorByName('', t('Replies to comments deeper than 1 is not allowed'));
}
break;
case "post_comment":
$form_state
->setErrorByName('', t('Replies for comments on posts are not allowed'));
break;
}
}
}