function hashtags_form_field_config_edit_form_alter in Hashtags 8
Implements hook_form_field_config_edit_form_alter().
File
- ./
hashtags.module, line 68
Code
function hashtags_form_field_config_edit_form_alter(&$form, FormStateInterface $form_state) {
if (!\Drupal::currentUser()
->hasPermission('administer hashtags')) {
return;
}
$field = $form_state
->getFormObject()
->getEntity();
$entity_type = $field
->getTargetEntityTypeId();
$bundle = $field
->getTargetBundle();
$field_type = $field
->getType();
$config = \Drupal::config('hashtags.settings');
$hashtags_field_name = $config
->get('hashtags_taxonomy_terms_field_name');
if (in_array($field_type, _hashtags_get_field_text_types()) && _hashtags_is_field_exists($entity_type, $bundle, $hashtags_field_name)) {
$form['field']['hashtags'] = [
'#type' => 'fieldset',
'#title' => t('Hashtags'),
'#collapsible' => TRUE,
'#collapsed' => FALSE,
];
$form['field']['hashtags']['hashtags_activate'] = [
'#type' => 'checkbox',
'#title' => t('Activate'),
'#description' => t('This allows to use hashtags for this field.'),
'#default_value' => $field
->getThirdPartySetting('hashtags', 'hashtags_activate', FALSE),
];
$form['actions']['submit']['#submit'][] = 'hashtags_form_field_config_edit_form_submit';
}
}