You are here

public function ColorFieldWidgetGrid::settingsForm in Color Field 8.2

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 WidgetBase::settingsForm

File

src/Plugin/Field/FieldWidget/ColorFieldWidgetGrid.php, line 39

Class

ColorFieldWidgetGrid
Plugin implementation of the 'color_field_default' widget.

Namespace

Drupal\color_field\Plugin\Field\FieldWidget

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $element = [];
  $element['cell_width'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Cell width'),
    '#default_value' => $this
      ->getSetting('cell_width'),
    '#required' => TRUE,
    '#description' => $this
      ->t('Width of each individual color cell.'),
  ];
  $element['cell_height'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Height width'),
    '#default_value' => $this
      ->getSetting('cell_height'),
    '#required' => TRUE,
    '#description' => $this
      ->t('Height of each individual color cell.'),
  ];
  $element['cell_margin'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Cell margin'),
    '#default_value' => $this
      ->getSetting('cell_margin'),
    '#required' => TRUE,
    '#description' => $this
      ->t('Margin of each individual color cell.'),
  ];
  $element['box_width'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Box width'),
    '#default_value' => $this
      ->getSetting('box_width'),
    '#required' => TRUE,
    '#description' => $this
      ->t('Width of the color display box.'),
  ];
  $element['box_height'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Box height'),
    '#default_value' => $this
      ->getSetting('box_height'),
    '#required' => TRUE,
    '#description' => $this
      ->t('Height of the color display box.'),
  ];
  $element['columns'] = [
    '#type' => 'textfield',
    '#title' => $this
      ->t('Columns number'),
    '#default_value' => $this
      ->getSetting('columns'),
    '#required' => TRUE,
    '#description' => $this
      ->t('Number of columns to display. Color order may look strange if this is altered.'),
  ];
  return $element;
}