public function ImageDeltaFormatter::settingsForm in Image Delta Formatter 8
Returns a form to configure settings for the formatter.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the formatter. The field_ui module takes care of handling submitted form values.
Parameters
array $form: The form where the settings form is being included in.
\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.
Return value
array The form elements for the formatter settings.
Overrides ImageFormatter::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ ImageDeltaFormatter.php, line 36
Class
- ImageDeltaFormatter
- Plugin implementation of the 'image_delta_formatter' formatter.
Namespace
Drupal\image_delta_formatter\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$element = parent::settingsForm($form, $form_state);
$element['deltas'] = [
'#type' => 'textfield',
'#title' => $this
->t('Delta'),
'#description' => $this
->t('Enter a delta, or a comma-separated list of deltas that should be shown. For example: 0, 1, 4.'),
'#size' => 10,
'#default_value' => $this
->getSetting('deltas'),
'#required' => TRUE,
'#weight' => -20,
];
$element['deltas_reversed'] = [
'#title' => $this
->t('Reversed'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('deltas_reversed'),
'#description' => $this
->t('Start from the last values.'),
'#weight' => -10,
];
return $element;
}