function fences_field_formatter_third_party_settings_form in Fences 8.2
Implements hook_field_formatter_third_party_settings_form().
File
- ./
fences.module, line 29 - Alter wrapping markup of fields.
Code
function fences_field_formatter_third_party_settings_form(FormatterInterface $plugin, FieldDefinitionInterface $field_definition, $view_mode, $form, FormStateInterface $form_state) {
$settings['fences'] = [];
$invisible_on_none = function ($name) {
return [
'invisible' => [
'[name$="' . $name . ']"]' => [
'value' => TagManagerInterface::NO_MARKUP_VALUE,
],
],
];
};
$tag_options = \Drupal::service('fences.tag_manager')
->getTagOptions();
$settings['fences'] = [
'#type' => 'fieldset',
'#title' => t('Fences'),
'#collapsed' => TRUE,
'#collapsible' => TRUE,
];
$settings['fences']['fences_field_tag'] = [
'#title' => t('Field Tag'),
'#type' => 'select',
'#options' => $tag_options,
'#default_value' => $plugin
->getThirdPartySetting('fences', 'fences_field_tag', 'div'),
];
$settings['fences']['fences_field_classes'] = [
'#title' => t('Field Classes'),
'#type' => 'textfield',
'#default_value' => $plugin
->getThirdPartySetting('fences', 'fences_field_classes'),
'#states' => $invisible_on_none('fences_field_tag'),
];
$settings['fences']['fences_field_item_tag'] = [
'#title' => t('Field Item Tag'),
'#type' => 'select',
'#options' => $tag_options,
'#default_value' => $plugin
->getThirdPartySetting('fences', 'fences_field_item_tag', 'div'),
];
$settings['fences']['fences_field_item_classes'] = [
'#title' => t('Field Item Classes'),
'#type' => 'textfield',
'#default_value' => $plugin
->getThirdPartySetting('fences', 'fences_field_item_classes'),
'#states' => $invisible_on_none('fences_field_item_tag'),
];
$settings['fences']['fences_label_tag'] = [
'#title' => t('Label Tag'),
'#type' => 'select',
'#options' => $tag_options,
'#default_value' => $plugin
->getThirdPartySetting('fences', 'fences_label_tag', 'div'),
];
$settings['fences']['fences_label_classes'] = [
'#title' => t('Label Classes'),
'#type' => 'textfield',
'#default_value' => $plugin
->getThirdPartySetting('fences', 'fences_label_classes'),
'#states' => $invisible_on_none('fences_label_tag'),
];
return $settings['fences'];
}