public function HtmlElement::settingsForm in Field Group 8
Same name and namespace in other branches
- 8.3 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 87
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'] = array(
'#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'] = array(
'#title' => $this
->t('Show label'),
'#type' => 'select',
'#options' => array(
0 => $this
->t('No'),
1 => $this
->t('Yes'),
),
'#default_value' => $this
->getSetting('show_label'),
'#weight' => 2,
'#attributes' => array(
'data-fieldgroup-selector' => 'show_label',
),
);
$form['label_element'] = array(
'#title' => $this
->t('Label element'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('label_element'),
'#weight' => 3,
'#states' => array(
'visible' => array(
':input[data-fieldgroup-selector="show_label"]' => array(
'value' => 1,
),
),
),
);
if ($this->context == 'form') {
$form['required_fields'] = array(
'#title' => $this
->t('Mark group as required if it contains required fields.'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('required_fields'),
'#weight' => 4,
);
}
$form['attributes'] = array(
'#title' => $this
->t('Attributes'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('attributes'),
'#description' => $this
->t('E.g. name="anchor"'),
'#weight' => 5,
);
$form['effect'] = array(
'#title' => $this
->t('Effect'),
'#type' => 'select',
'#options' => array(
'none' => $this
->t('None'),
'collapsible' => $this
->t('Collapsible'),
'blind' => $this
->t('Blind'),
),
'#default_value' => $this
->getSetting('effect'),
'#weight' => 6,
'#attributes' => array(
'data-fieldgroup-selector' => 'effect',
),
);
$form['speed'] = array(
'#title' => $this
->t('Speed'),
'#type' => 'select',
'#options' => array(
'slow' => $this
->t('Slow'),
'fast' => $this
->t('Fast'),
),
'#default_value' => $this
->getSetting('speed'),
'#weight' => 7,
'#states' => array(
'!visible' => array(
':input[data-fieldgroup-selector="effect"]' => array(
'value' => 'none',
),
),
),
);
return $form;
}