public function TwentyTwentyFieldFormatter::settingsForm in ZURB TwentyTwenty 8
Same name and namespace in other branches
- 2.0.x src/Plugin/Field/FieldFormatter/TwentyTwentyFieldFormatter.php \Drupal\zurb_twentytwenty\Plugin\Field\FieldFormatter\TwentyTwentyFieldFormatter::settingsForm()
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 FormatterBase::settingsForm
File
- src/
Plugin/ Field/ FieldFormatter/ TwentyTwentyFieldFormatter.php, line 110 - Contains Drupal\zurb_twentytwenty\Plugin\Field\FieldFormatter\TwentyTwentyFieldFormatter.
Class
- TwentyTwentyFieldFormatter
- Plugin implementation of the 'twentytwenty_field_formatter' formatter.
Namespace
Drupal\zurb_twentytwenty\Plugin\Field\FieldFormatterCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$image_styles = image_style_options(FALSE);
$description_link = Link::fromTextAndUrl($this
->t('Configure Image Styles'), Url::fromRoute('entity.image_style.collection'));
$element['image_style'] = [
'#title' => $this
->t('Image style'),
'#type' => 'select',
'#default_value' => $this
->getSetting('image_style'),
'#empty_option' => $this
->t('None (original image)'),
'#options' => $image_styles,
'#description' => $description_link
->toRenderable() + [
'#access' => $this->currentUser
->hasPermission('administer image styles'),
],
];
$element['default_offset_pct'] = [
'#title' => $this
->t('Default Offset (Percent)'),
'#description' => $this
->t('Select an offset between 0 and 1 to set how far the slider is from the lefthand side when it loads. The default is 0.5.'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('default_offset_pct'),
];
$element['orientation'] = [
'#title' => $this
->t('Orientation'),
'#description' => $this
->t('The default is orientation'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('orientation'),
];
$element['before_label'] = [
'#title' => $this
->t('Before label'),
'#description' => $this
->t('The default is before'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('before_label'),
];
$element['after_label'] = [
'#title' => $this
->t('After label'),
'#description' => $this
->t('The default is after'),
'#type' => 'textfield',
'#default_value' => $this
->getSetting('after_label'),
];
$element['no_overlay'] = [
'#title' => $this
->t('No overlay'),
'#description' => $this
->t('The default is false'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('no_overlay'),
];
$element['move_slider_on_hover'] = [
'#title' => $this
->t('Move slider on hover'),
'#description' => $this
->t('The default is false'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('move_slider_on_hover'),
];
$element['move_with_handle_only'] = [
'#title' => $this
->t('Move with handle only'),
'#description' => $this
->t('The default is true'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('move_with_handle_only'),
];
$element['click_to_move'] = [
'#title' => $this
->t('Click to move'),
'#description' => $this
->t('The default is false'),
'#type' => 'checkbox',
'#default_value' => $this
->getSetting('click_to_move'),
];
return $element;
}