function social_event_form_views_exposed_form_alter in Open Social 8.4
Same name and namespace in other branches
- 8.9 modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 8 modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 8.2 modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 8.3 modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 8.5 modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 8.6 modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 8.7 modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 8.8 modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 10.3.x modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 10.0.x modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 10.1.x modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
- 10.2.x modules/social_features/social_event/social_event.module \social_event_form_views_exposed_form_alter()
Implements hook_form_form_ID_alter().
Enhance the exposed filter form of the event overview.
File
- modules/
social_features/ social_event/ social_event.module, line 33 - The Social event module.
Code
function social_event_form_views_exposed_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if ($form['#id'] === 'views-exposed-form-events-events-overview') {
$form['status']['#options'][0] = t('Unpublished');
$form['status']['#options'][1] = t('Published');
$account_uid = \Drupal::routeMatch()
->getParameter('user');
$current_uid = \Drupal::currentUser()
->id();
if ($account_uid !== $current_uid) {
$form['status']['#access'] = FALSE;
}
// Enable the reset button.
// @todo make sure the block content refreshes on submit as well (AJAX).
$form['actions']['reset']['#access'] = TRUE;
// @todo make sure exposed form filtering redirects to the proper view
// page, when views is updated.
$form['#action'] = '/user/' . $account_uid . '/events';
}
if ($form['#id'] === 'views-exposed-form-group-events-page-group-events') {
$group_from_route = _social_group_get_current_group();
// Get group from route.
if (!empty($group_from_route)) {
$group_id = $group_from_route
->id();
}
$form['actions']['reset']['#access'] = TRUE;
// Make sure we redirect to the current group page.
$form['#action'] = '/group/' . $group_id . '/events';
}
}