You are here

public function Acquiadam::getFilterSort in Media: Acquia DAM 8

Create form elements for sorting and filtering/searching.

1 call to Acquiadam::getFilterSort()
Acquiadam::getForm in src/Plugin/EntityBrowser/Widget/Acquiadam.php

File

src/Plugin/EntityBrowser/Widget/Acquiadam.php, line 456

Class

Acquiadam
Uses a view to provide entity listing in a browser's widget.

Namespace

Drupal\media_acquiadam\Plugin\EntityBrowser\Widget

Code

public function getFilterSort() {

  // Add container for pager.
  $form['filter-sort-container'] = [
    '#type' => 'container',
    '#attributes' => [
      'class' => [
        'filter-sort-container',
      ],
    ],
  ];

  // Add dropdown for sort by.
  $form['filter-sort-container']['sortby'] = [
    '#type' => 'select',
    '#title' => 'Sort by',
    '#options' => [
      'filename' => 'File name',
      'filesize' => 'File size',
      'datecreated' => 'Date created',
      'datemodified' => 'Date modified',
    ],
    '#default_value' => 'datecreated',
  ];

  // Add dropdown for sort direction.
  $form['filter-sort-container']['sortdir'] = [
    '#type' => 'select',
    '#title' => 'Sort direction',
    '#options' => [
      'asc' => 'Ascending',
      'desc' => 'Descending',
    ],
    '#default_value' => 'asc',
  ];

  // Add dropdown for filtering on asset type.
  $form['filter-sort-container']['types'] = [
    '#type' => 'select',
    '#title' => 'File type',
    '#options' => [
      '' => 'All',
      'image' => 'Image',
      'audiovideo' => 'Audio/Video',
      'document' => 'Document',
      'presentation' => 'Presentation',
      'other' => 'Other',
    ],
    '#default_value' => '',
  ];

  // Add textfield for keyword search.
  $form['filter-sort-container']['query'] = [
    '#type' => 'textfield',
    '#title' => 'Search',
    '#size' => 24,
  ];

  // Add submit button to apply sort/filter criteria.
  $form['filter-sort-container']['filter-sort-submit'] = [
    '#type' => 'button',
    '#value' => 'Apply',
    '#name' => 'filter_sort_submit',
  ];

  // Add form reset button.
  $form['filter-sort-container']['filter-sort-reset'] = [
    '#type' => 'button',
    '#value' => 'Reset',
    '#name' => 'filter_sort_reset',
  ];
  return $form;
}