public function Dropdown::selectionElement in Image Effects 8
Same name in this branch
- 8 src/Plugin/image_effects/FontSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\FontSelector\Dropdown::selectionElement()
 - 8 src/Plugin/image_effects/ImageSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\ImageSelector\Dropdown::selectionElement()
 
Same name and namespace in other branches
- 8.3 src/Plugin/image_effects/ImageSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\ImageSelector\Dropdown::selectionElement()
 - 8.2 src/Plugin/image_effects/ImageSelector/Dropdown.php \Drupal\image_effects\Plugin\image_effects\ImageSelector\Dropdown::selectionElement()
 
Return a form element to select the plugin content.
Parameters
array $options: (Optional) An array of additional Form API keys and values.
Return value
array Render array of the form element.
Overrides ImageEffectsPluginBase::selectionElement
File
- src/
Plugin/ image_effects/ ImageSelector/ Dropdown.php, line 104  
Class
- Dropdown
 - Dropdown image selector plugin.
 
Namespace
Drupal\image_effects\Plugin\image_effects\ImageSelectorCode
public function selectionElement(array $options = []) {
  // Get list of images.
  $image_files = $this
    ->getList();
  if (empty($image_files)) {
    drupal_set_message($this
      ->t('No images available. Make sure at least one image is available in the directory specified in the <a href=":url">configuration page</a>.', [
      ':url' => Url::fromRoute('image_effects.settings')
        ->toString(),
    ]), 'warning');
  }
  // Strip the path from the URI.
  $options['#default_value'] = isset($options['#default_value']) ? pathinfo($options['#default_value'], PATHINFO_BASENAME) : '';
  // Element.
  return array_merge([
    '#type' => 'select',
    '#title' => $this
      ->t('Image'),
    '#description' => $this
      ->t('Select an image.'),
    '#options' => array_combine($image_files, $image_files),
    '#element_validate' => [
      [
        $this,
        'validateSelectorUri',
      ],
    ],
  ], $options);
}