public function HtmlElement::settingsForm in Field Group 8.3
Same name and namespace in other branches
- 8 src/Plugin/field_group/FieldGroupFormatter/HtmlElement.php \Drupal\field_group\Plugin\field_group\FieldGroupFormatter\HtmlElement::settingsForm()
Returns a form to configure settings for the formatter.
Invoked in field_group_field_ui_display_form_alter to allow administrators to configure the formatter. The field_group module takes care of handling submitted form values.
Return value
array The form elements for the formatter settings.
Overrides FieldGroupFormatterBase::settingsForm
File
- src/
Plugin/ field_group/ FieldGroupFormatter/ HtmlElement.php, line 109
Class
- HtmlElement
- Plugin implementation of the 'html_element' formatter.
Namespace
Drupal\field_group\Plugin\field_group\FieldGroupFormatterCode
public function settingsForm() {
$form = parent::settingsForm();
$form['element'] = [
'#title' => $this
->t('Element'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('element'),
'#description' => $this
->t('E.g. div, section, aside etc.'),
'#weight' => 1,
];
$form['show_label'] = [
'#title' => $this
->t('Show label'),
'#type' => 'select',
'#options' => [
0 => $this
->t('No'),
1 => $this
->t('Yes'),
],
'#default_value' => $this
->getSetting('show_label'),
'#weight' => 2,
'#attributes' => [
'data-fieldgroup-selector' => 'show_label',
],
];
$form['label_element'] = [
'#title' => $this
->t('Label element'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('label_element'),
'#weight' => 3,
'#states' => [
'visible' => [
':input[data-fieldgroup-selector="show_label"]' => [
'value' => 1,
],
],
],
];
$form['label_element_classes'] = [
'#title' => $this
->t('Label element HTML classes'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('label_element_classes'),
'#weight' => 3,
'#states' => [
'visible' => [
':input[data-fieldgroup-selector="show_label"]' => [
'value' => 1,
],
],
],
];
if ($this->context == 'form') {
$form['required_fields'] = [
'#title' => $this
->t('Mark group as required if it contains required fields.'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('required_fields'),
'#weight' => 4,
];
}
$form['attributes'] = [
'#title' => $this
->t('Attributes'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('attributes'),
'#description' => $this
->t('E.g. name="anchor"'),
'#weight' => 5,
];
$form['effect'] = [
'#title' => $this
->t('Effect'),
'#type' => 'select',
'#options' => [
'none' => $this
->t('None'),
'collapsible' => $this
->t('Collapsible'),
'blind' => $this
->t('Blind'),
],
'#default_value' => $this
->getSetting('effect'),
'#weight' => 6,
'#attributes' => [
'data-fieldgroup-selector' => 'effect',
],
];
$form['speed'] = [
'#title' => $this
->t('Speed'),
'#type' => 'select',
'#options' => [
'slow' => $this
->t('Slow'),
'fast' => $this
->t('Fast'),
],
'#default_value' => $this
->getSetting('speed'),
'#weight' => 7,
'#states' => [
'!visible' => [
':input[data-fieldgroup-selector="effect"]' => [
'value' => 'none',
],
],
],
];
return $form;
}