You are here

public function MediaThumbnailConfigForm::buildForm in Media Thumbnails 8

Form constructor.

Parameters

array $form: An associative array containing the structure of the form.

\Drupal\Core\Form\FormStateInterface $form_state: The current state of the form.

Return value

array The form structure.

Overrides ConfigFormBase::buildForm

File

src/Form/MediaThumbnailConfigForm.php, line 51

Class

MediaThumbnailConfigForm
Implements the media thumbnails config form.

Namespace

Drupal\media_thumbnails\Form

Code

public function buildForm(array $form, FormStateInterface $form_state) {
  $form['width'] = [
    '#default_value' => $this
      ->config('media_thumbnails.settings')
      ->get('width'),
    '#description' => $this
      ->t('The width for the generated thumbnails. Height will be calculated automatically.'),
    '#title' => $this
      ->t('Thumbnail width'),
    '#type' => 'number',
  ];
  $form['bgcolor'] = [
    '#collapsed' => FALSE,
    '#collapsible' => TRUE,
    '#title' => t('Background color'),
    '#type' => 'fieldset',
  ];
  $form['bgcolor']['bgcolor_active'] = [
    '#default_value' => $this
      ->config('media_thumbnails.settings')
      ->get('bgcolor_active'),
    '#title' => $this
      ->t('Add a custom background color. Uncheck to keep transparency.'),
    '#type' => 'checkbox',
  ];
  $form['bgcolor']['bgcolor_value'] = [
    '#default_value' => $this
      ->config('media_thumbnails.settings')
      ->get('bgcolor_value'),
    '#description' => $this
      ->t('Background color for transparent thumbnails, for plugins supporting this feature.'),
    '#title' => $this
      ->t('Background color'),
    '#type' => 'color',
  ];
  return parent::buildForm($form, $form_state);
}