public function JqueryMinicolorsWidget::settingsForm in jQuery minicolors 8
Returns a form to configure settings for the widget.
Invoked from \Drupal\field_ui\Form\EntityDisplayFormBase to allow administrators to configure the widget. 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 definition for the widget settings.
Overrides StringTextfieldWidget::settingsForm
File
- src/
Plugin/ Field/ FieldWidget/ JqueryMinicolorsWidget.php, line 49
Class
- JqueryMinicolorsWidget
- Plugin implementation of the 'jquery_minicolors_widget' widget.
Namespace
Drupal\jquery_minicolors\Plugin\Field\FieldWidgetCode
public function settingsForm(array $form, FormStateInterface $form_state) {
$elements = parent::settingsForm($form, $form_state);
$control = [
'hue' => $this
->t('Hue'),
'brightness' => $this
->t('Brightness'),
'saturation' => $this
->t('Saturation'),
'wheel' => $this
->t('Wheel'),
];
$elements['control'] = array(
'#type' => 'select',
'#title' => $this
->t('Control'),
'#options' => $control,
'#default_value' => $this
->getSetting('control'),
'#description' => $this
->t('Determines the type of control.'),
);
$format = [
'hex' => $this
->t('Hexadecimal'),
'rgb' => $this
->t('RGB notation'),
];
$elements['format'] = array(
'#type' => 'select',
'#title' => $this
->t('Format'),
'#options' => $format,
'#default_value' => $this
->getSetting('format'),
'#description' => $this
->t('The format miniColors should use.'),
);
$elements['opacity'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Opacity'),
'#empty' => 0,
'#return_value' => 1,
'#default_value' => $this
->getSetting('opacity'),
'#description' => $this
->t('Check this option to enable the opacity slider.'),
);
$elements['swatches'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Swatches'),
'#default_value' => $this
->getSetting('swatches'),
'#description' => $this
->t('A list separated by pipe of colors, in either rgb(a) or hex format, that will show up under the main color grid. There can be only up to 7 colors.'),
);
$position = [
'bottom left' => $this
->t('Bottom left'),
'bottom right' => $this
->t('Bottom right'),
'top left' => $this
->t('Top left'),
'top right' => $this
->t('Top right'),
];
$elements['position'] = array(
'#type' => 'select',
'#title' => $this
->t('Position'),
'#options' => $position,
'#default_value' => $this
->getSetting('position'),
'#description' => $this
->t('Sets the position of the dropdown.'),
);
$theme = [
'default' => $this
->t('Default'),
'bootstrap' => $this
->t('Bootstrap'),
];
$elements['theme'] = array(
'#type' => 'select',
'#title' => $this
->t('Theme'),
'#options' => $theme,
'#default_value' => $this
->getSetting('theme'),
'#description' => $this
->t('jQuery minicolors library provide support for bootstrap theme. Select the theme you want to use for prefixing the selectors.'),
);
$elements['inline'] = array(
'#type' => 'checkbox',
'#title' => $this
->t('Inline'),
'#empty' => 0,
'#return_value' => 1,
'#default_value' => $this
->getSetting('inline'),
'#description' => $this
->t('Check this option to force the color picker to appear inline.'),
);
$elements['animation_speed'] = array(
'#type' => 'number',
'#title' => $this
->t('Animation Speed'),
'#default_value' => $this
->getSetting('animation_speed'),
'#description' => $this
->t('The animation speed, in milliseconds, of the sliders when the user taps or clicks a new color. Set to 0 for no animation.'),
);
$elements['animation_easing'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Animation Easing'),
'#default_value' => $this
->getSetting('animation_easing'),
'#description' => $this
->t('The easing to use when animating the sliders.'),
);
$elements['change_delay'] = array(
'#type' => 'number',
'#title' => $this
->t('Change Delay'),
'#default_value' => $this
->getSetting('change_delay'),
'#description' => $this
->t('The time, in milliseconds, to defer the change event from firing while the user makes a selection. This is useful for preventing the change event from firing frequently as the user drags the color picker around.'),
);
$letter_case = [
'uppercase' => $this
->t('Uppercase'),
'lowercase' => $this
->t('Lowercase'),
];
$elements['letter_case'] = array(
'#type' => 'select',
'#title' => $this
->t('Letter Case'),
'#options' => $letter_case,
'#default_value' => $this
->getSetting('letter_case'),
'#description' => $this
->t('Determines the letter case of the hex code value.'),
);
$elements['show_speed'] = array(
'#type' => 'number',
'#title' => $this
->t('Show speed'),
'#default_value' => $this
->getSetting('show_speed'),
'#description' => $this
->t('The speed, in milliseconds, at which to show the color picker.'),
);
$elements['hide_speed'] = array(
'#type' => 'number',
'#title' => $this
->t('Hide speed'),
'#default_value' => $this
->getSetting('hide_speed'),
'#description' => $this
->t('The speed, in milliseconds, at which to hide the color picker.'),
);
$elements['keywords'] = array(
'#type' => 'textfield',
'#title' => $this
->t('Keywords'),
'#default_value' => $this
->getSetting('keywords'),
'#description' => $this
->t('A comma-separated list of keywords that the control should accept (e.g. inherit, transparent, initial).'),
);
return $elements;
}