function soft_length_limit_field_widget_third_party_settings_form in Soft Length Limit 8
Implements hook_field_widget_third_party_settings_form().
File
- ./
soft_length_limit.module, line 58
Code
function soft_length_limit_field_widget_third_party_settings_form(WidgetInterface $plugin, FieldDefinitionInterface $field_definition, $form_mode, $form, FormStateInterface $form_state) {
$plugin_id = $plugin
->getPluginId();
if (!($allowed_settings = _soft_length_widget_settings($plugin_id))) {
return NULL;
}
$element = [];
if ($allowed_settings['max_limit']) {
$element['max_limit'] = [
'#type' => 'number',
'#min' => 0,
'#title' => t('Soft length limit'),
'#default_value' => $plugin
->getThirdPartySetting('soft_length_limit', 'max_limit'),
'#description' => t('If any value is given here, a counter will appear next to this field, informing the user of the chosen number of allowed characters. If the number is exceeded, a warning will be shown.'),
'#weight' => -3,
];
}
if ($allowed_settings['minimum_limit']) {
$element['minimum_limit'] = [
'#type' => 'number',
'#min' => 0,
'#title' => t('Soft length minimum'),
'#default_value' => $plugin
->getThirdPartySetting('soft_length_limit', 'minimum_limit'),
'#description' => t('If any value is given here, the minimum number recommended characters will be displayed as the editor enters text in this field.'),
'#weight' => -2,
];
}
if ($allowed_settings['style_select']) {
$element['style_select'] = [
'#type' => 'checkbox',
'#title' => t('Enable enhanced view'),
'#default_value' => $plugin
->getThirdPartySetting('soft_length_limit', 'style_select'),
'#description' => t('Check this to enable an enhanced view of soft length states.'),
'#weight' => -1,
];
}
return $element;
}