You are here

public static function EntityBrowserPagerElement::submitPager in Entity Browser 8

Same name and namespace in other branches
  1. 8.2 src/Element/EntityBrowserPagerElement.php \Drupal\entity_browser\Element\EntityBrowserPagerElement::submitPager()

Submit handler for next and previous buttons.

Parameters

array $form: The form.

\Drupal\Core\Form\FormStateInterface $form_state: Form state.

File

src/Element/EntityBrowserPagerElement.php, line 95

Class

EntityBrowserPagerElement
Provides an Entity Browser pager form element.

Namespace

Drupal\entity_browser\Element

Code

public static function submitPager(array $form, FormStateInterface $form_state) {
  $page = static::getCurrentPage($form_state);
  $triggering_element = $form_state
    ->getTriggeringElement();
  if ($triggering_element['#name'] == 'prev_page') {
    $page--;
  }
  elseif ($triggering_element['#name'] == 'next_page') {
    $page++;
  }
  $form_state
    ->set('page', $page);
  $form_state
    ->setRebuild();
}