function social_tagging_form_taxonomy_term_social_tagging_form_alter in Open Social 8.6
Same name and namespace in other branches
- 8.9 modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 8 modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 8.2 modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 8.3 modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 8.4 modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 8.5 modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 8.7 modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 8.8 modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 10.3.x modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 10.0.x modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 10.1.x modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
- 10.2.x modules/social_features/social_tagging/social_tagging.module \social_tagging_form_taxonomy_term_social_tagging_form_alter()
Implements hook_form_FORM_ID_alter().
File
- modules/
social_features/ social_tagging/ social_tagging.module, line 46 - Contains social_tagging.module.
Code
function social_tagging_form_taxonomy_term_social_tagging_form_alter(&$form, FormStateInterface $form_state, $form_id) {
// Load all taxonomy terms from the top level.
$tag_service = Drupal::getContainer()
->get('social_tagging.tag_service');
// Remove these fields.
$form['path']['#access'] = FALSE;
$form['relations']['#access'] = FALSE;
$form['description']['#access'] = FALSE;
// Move it outside the details.
$form['parent'] = $form['relations']['parent'];
unset($form['relations']['parent']);
// Make some changes.
$form['weight']['#access'] = FALSE;
$form['parent']['#title'] = t('Placement');
// Fetch all top level items.
$options = $tag_service
->getCategories();
// Add the 0 option for a new toplevel item.
$options[0] = t('Main category');
// Sort the array.
ksort($options);
// Add it to the select.
$form['parent']['#options'] = $options;
}