function og_menu_form_alter in Organic Groups Menu (OG Menu) 8
Same name and namespace in other branches
- 5 og_menu.module \og_menu_form_alter()
- 6.2 og_menu.module \og_menu_form_alter()
- 6 og_menu.module \og_menu_form_alter()
- 7.3 og_menu.module \og_menu_form_alter()
- 7.2 og_menu.module \og_menu_form_alter()
Implements hook_form_alter().
File
- ./
og_menu.module, line 82 - Main functions and hook implementations of the og_menu module.
Code
function og_menu_form_alter(&$form, FormStateInterface $form_state, $form_id) {
if (in_array($form_id, [
'ogmenu_add_form',
'ogmenu_edit_form',
])) {
// Behind the scenes an OG Menu is a group content type that is associated
// with its chosen group types. We are using the standard fieldset that is
// altered in by Organic Groups in entity bundle forms to configure the
// group types.
// By default the options provided by Organic Groups allow to turn any
// bundle in a group type or group content type, but this doesn't make sense
// for us.
// Alter the form so that the option to become group content is always
// enabled, and hide the group type / group content type options so they
// cannot be accidentally changed by an administrator.
$form['og']['og_is_group']['#access'] = FALSE;
$form['og']['og_group_content_bundle']['#access'] = FALSE;
$form['og']['og_group_content_bundle']['#default_value'] = TRUE;
// Make sure the OG fieldset is open, since the group type options are
// important for us.
$form['og']['#open'] = TRUE;
// Update the help texts so they make more sense in the context of OG Menu.
unset($form['og']['#description']);
$form['og']['og_target_type']['#description'] = t('The entity type of the groups to associate the OG Menu with.');
$form['og']['og_target_bundles']['#description'] = t('The bundles of the entity type to associate the OG Menu with. Optional, leave empty for all bundles.');
}
}