You are here

function entity_browser_form_views_ui_add_handler_form_alter in Entity Browser 8.2

Same name and namespace in other branches
  1. 8 entity_browser.module \entity_browser_form_views_ui_add_handler_form_alter()

Implements hook_form_FORM_ID_alter().

File

./entity_browser.module, line 205
Allows to flexibly create, browse and select entities.

Code

function entity_browser_form_views_ui_add_handler_form_alter(&$form, FormStateInterface $form_state) {

  // Hide 'entity_browser_bundle' views filter plugin for displays other than
  // entity_browser.
  $display_id = $form_state
    ->get('display_id');
  $display_plugin = $form_state
    ->get('view')
    ->get('storage')
    ->get('display')[$display_id]['display_plugin'];
  if ($display_plugin != 'entity_browser') {
    foreach ($form['options']['name']['#options'] as $key => $value) {
      if (strpos($key, 'entity_browser_bundle') !== FALSE) {
        unset($form['options']['name']['#options'][$key]);
      }
    }
  }
}