function allowed_formats_form_field_config_edit_form_alter in Allowed Formats 8
Implements hook_form_FORM_ID_form_alter().
File
- ./
allowed_formats.module, line 18 - This is the allowed_formats module.
Code
function allowed_formats_form_field_config_edit_form_alter(array &$form, FormStateInterface $form_state) {
/** @var \Drupal\Core\Field\FieldConfigInterface $field */
$field = $form_state
->getFormObject()
->getEntity();
if (in_array($field
->getType(), _allowed_formats_field_types())) {
$options = [];
foreach (filter_formats() as $format) {
$options[$format
->id()] = $format
->label();
}
$form['third_party_settings']['allowed_formats'] = [
'#type' => 'checkboxes',
'#title' => t('Allowed formats'),
'#options' => $options,
'#default_value' => $field
->getThirdPartySettings('allowed_formats'),
'#description' => t('Restrict which text formats are allowed, given the user has the required permissions. If no text formats are selected, then all the ones the user has access to will be available.'),
];
}
}