function search_api_exclude_form_node_type_form_alter in Search API exclude 8
Same name and namespace in other branches
- 7 search_api_exclude.module \search_api_exclude_form_node_type_form_alter()
Implements hook_form_FORM_ID_alter().
File
- ./
search_api_exclude.module, line 57 - Allows users to exclude specific nodes from indexing by Search API.
Code
function search_api_exclude_form_node_type_form_alter(&$form, FormStateInterface $form_state) {
/** @var \Drupal\node\NodeTypeInterface $type */
$type = $form_state
->getFormObject()
->getEntity();
$form['search_api_exclude'] = [
'#type' => 'details',
'#title' => t('Search API Exclude'),
'#group' => 'additional_settings',
];
$form['search_api_exclude']['search_api_exclude_enabled'] = [
'#type' => 'checkbox',
'#title' => t('Enabled'),
'#default_value' => $type
->getThirdPartySetting('search_api_exclude', 'enabled', FALSE),
'#description' => t('Allow setting the inclusivity of a node.'),
];
$form['#entity_builders'][] = 'search_api_exclude_form_node_type_form_builder';
}