You are here

public function AccordionItem::settingsForm in Field Group 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/field_group/FieldGroupFormatter/AccordionItem.php \Drupal\field_group\Plugin\field_group\FieldGroupFormatter\AccordionItem::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/AccordionItem.php, line 59

Class

AccordionItem
Plugin implementation of the 'accordion_item' formatter.

Namespace

Drupal\field_group\Plugin\field_group\FieldGroupFormatter

Code

public function settingsForm() {
  $form = parent::settingsForm();
  $form['formatter'] = array(
    '#title' => $this
      ->t('Default state'),
    '#type' => 'select',
    '#options' => array_combine($this->pluginDefinition['format_types'], $this->pluginDefinition['format_types']),
    '#default_value' => $this
      ->getSetting('formatter'),
    '#weight' => -4,
  );
  if ($this->context == 'form') {
    $form['required_fields'] = array(
      '#type' => 'checkbox',
      '#title' => $this
        ->t('Mark group as required if it contains required fields.'),
      '#default_value' => $this
        ->getSetting('required_fields'),
      '#weight' => 2,
    );
  }
  return $form;
}