You are here

public function MobileDeviceDetectionExtenderPlugin::buildOptionsForm in Mobile Device Detection 8

Same name and namespace in other branches
  1. 8.3 src/Plugin/views/display_extender/MobileDeviceDetectionExtenderPlugin.php \Drupal\mobile_device_detection\Plugin\views\display_extender\MobileDeviceDetectionExtenderPlugin::buildOptionsForm()
  2. 8.2 src/Plugin/views/display_extender/MobileDeviceDetectionExtenderPlugin.php \Drupal\mobile_device_detection\Plugin\views\display_extender\MobileDeviceDetectionExtenderPlugin::buildOptionsForm()

Provide a form to edit options for this plugin.

Overrides DisplayExtenderPluginBase::buildOptionsForm

File

src/Plugin/views/display_extender/MobileDeviceDetectionExtenderPlugin.php, line 54

Class

MobileDeviceDetectionExtenderPlugin
Default display extender plugin; does nothing.

Namespace

Drupal\mobile_device_detection\Plugin\views\display_extender

Code

public function buildOptionsForm(&$form, FormStateInterface $form_state) {
  if ($form_state
    ->get('section') == 'device_detection') {
    $form['#title'] .= $this
      ->t('Show "View" on special devices');
    $form['device_detection']['#type'] = 'container';
    $form['device_detection']['#tree'] = TRUE;
    $form['device_detection']['devices'] = array(
      '#type' => 'checkboxes',
      '#options' => [
        'mobile' => $this
          ->t('Mobile'),
        'tablet' => $this
          ->t('Tablet'),
        'desktop' => $this
          ->t('Desktop'),
      ],
      '#default_value' => $this
        ->getDevices() ? $this
        ->getDevices() : [],
      '#title' => $this
        ->t('Select device'),
    );
  }
}