You are here

function social_post_album_form_comment_post_comment_form_alter in Open Social 10.3.x

Same name and namespace in other branches
  1. 10.0.x modules/social_features/social_post/modules/social_post_album/social_post_album.module \social_post_album_form_comment_post_comment_form_alter()
  2. 10.1.x modules/social_features/social_post/modules/social_post_album/social_post_album.module \social_post_album_form_comment_post_comment_form_alter()
  3. 10.2.x modules/social_features/social_post/modules/social_post_album/social_post_album.module \social_post_album_form_comment_post_comment_form_alter()

Implements hook_form_FORM_ID_alter().

File

modules/social_features/social_post/modules/social_post_album/social_post_album.module, line 170
The Social post album module.

Code

function social_post_album_form_comment_post_comment_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $route_names = [
    'social_post_album.ajax_comments.add',
    'social_post_album.image_popup_render_original',
  ];
  if (\Drupal::moduleHandler()
    ->moduleExists('social_ajax_comments') && in_array(\Drupal::routeMatch()
    ->getRouteName(), $route_names)) {

    /** @var \Drupal\Core\Url $url */
    $url =& $form['actions']['submit']['#ajax']['url'];
    if ($url
      ->getRouteName() === 'ajax_comments.add') {
      $url = Url::fromRoute('social_post_album.ajax_comments.add', $url
        ->getRouteParameters(), $url
        ->getOptions());
    }
  }
}