You are here

function social_path_manager_form_alter in Open Social 8.7

Same name and namespace in other branches
  1. 8.9 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_form_alter()
  2. 8.5 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_form_alter()
  3. 8.6 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_form_alter()
  4. 8.8 modules/custom/social_path_manager/social_path_manager.module \social_path_manager_form_alter()
  5. 10.3.x modules/custom/social_path_manager/social_path_manager.module \social_path_manager_form_alter()
  6. 10.0.x modules/custom/social_path_manager/social_path_manager.module \social_path_manager_form_alter()
  7. 10.1.x modules/custom/social_path_manager/social_path_manager.module \social_path_manager_form_alter()
  8. 10.2.x modules/custom/social_path_manager/social_path_manager.module \social_path_manager_form_alter()

Implements hook_form_alter().

File

modules/custom/social_path_manager/social_path_manager.module, line 18
The Social Path Manager module.

Code

function social_path_manager_form_alter(&$form, FormStateInterface $form_state, $form_id) {
  $social_group_types = _social_path_manager_group_types();
  $group_forms = [];
  foreach ($social_group_types as $social_group_type) {
    $group_forms['edit'][] = "group_{$social_group_type}_edit_form";
    $group_forms['add'][] = "group_{$social_group_type}_add_form";
  }
  if (in_array($form_id, $group_forms['add'], TRUE) || in_array($form_id, $group_forms['edit'], TRUE)) {
    $form['path']['#type'] = 'fieldset';
  }
  $user_forms = [
    'user_register_form',
    'user_form',
  ];

  // Hide the URL alias for user forms, doesn't do anything.
  if (!empty($form['path']) && in_array($form_id, $user_forms, TRUE)) {
    unset($form['path']);
  }
}