You are here

public function FlickrFilter::settingsForm in Flickr 8

Generates a filter's settings form.

Parameters

array $form: A minimally prepopulated form array.

\Drupal\Core\Form\FormStateInterface $form_state: The state of the (entire) configuration form.

Return value

array The $form array with additional form elements for the settings of this filter. The submitted form values should match $this->settings.

Overrides FilterBase::settingsForm

File

modules/flickr_filter/src/Plugin/Filter/FlickrFilter.php, line 113

Class

FlickrFilter
Provides a filter to insert Flickr photo.

Namespace

Drupal\flickr_filter\Plugin\Filter

Code

public function settingsForm(array $form, FormStateInterface $form_state) {
  $sizes = $this->helpers->flickrApiHelpers
    ->photoSizes();
  foreach ($sizes as $key => $size) {
    $options[$key] = $size['description']
      ->render();
  }
  $form['flickr_filter_default_size'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Default size for single photos'),
    '#default_value' => $this->settings['flickr_filter_default_size'],
    '#options' => $options,
    '#description' => $this
      ->t("A default Flickr size to use if no size is specified, for example [flickr-photo:id=3711935987].<br />TAKE CARE, the c size (800px) is missing on Flickr images uploaded before March 1, 2012!"),
  ];
  $form['flickr_filter_caption'] = [
    '#type' => 'select',
    '#title' => $this
      ->t('Display captions for every Flickr photo'),
    '#required' => TRUE,
    '#default_value' => $this->settings['flickr_filter_caption'],
    '#description' => $this
      ->t("If selected, flickr photos will display caption."),
    '#options' => [
      0 => 'No',
      1 => 'Yes',
    ],
  ];
  return $form;
}