function ColorizeImageEffect::buildConfigurationForm

File

modules/image_example/src/Plugin/ImageEffect/ColorizeImageEffect.php, line 106

Class

ColorizeImageEffect
Colorizes an image resource.

Namespace

Drupal\image_example\Plugin\ImageEffect

Code

public function buildConfigurationForm(array $form, FormStateInterface $form_state) {
  // You do not need to worry about saving/updating/deleting the collected
  // data. The Image module will automatically serialize and store all the
  // data associated with an effect.
  $form['color'] = [
    '#type' => 'textfield',
    '#title' => $this->t('Color'),
    '#description' => $this->t('The color to use when colorizing the image. Use web-style hex colors, for example %long-value, or %short-value.', [
      '%long-value' => '#FF6633',
      '%short-value' => 'F63',
    ]),
    '#default_value' => $this->configuration['color'] ?? '',
    '#size' => 7,
    '#max_length' => 7,
    '#required' => TRUE,
  ];
  return $form;
}