You are here

protected function ConfigSplitEntityForm::useSelectList in Configuration Split 8

Same name and namespace in other branches
  1. 2.0.x src/Form/ConfigSplitEntityForm.php \Drupal\config_split\Form\ConfigSplitEntityForm::useSelectList()

If the chosen or select2 module is active, the form must use select field.

Return value

bool True if the form must use a select field

2 calls to ConfigSplitEntityForm::useSelectList()
ConfigSplitEntityForm::form in src/Form/ConfigSplitEntityForm.php
Gets the actual form array to be built.
ConfigSplitEntityForm::readValuesFromPicker in src/Form/ConfigSplitEntityForm.php
Read values selected depending on widget used: select or checkbox.

File

src/Form/ConfigSplitEntityForm.php, line 275

Class

ConfigSplitEntityForm
The entity form.

Namespace

Drupal\config_split\Form

Code

protected function useSelectList() {

  // Allow the setting to be overwritten with the drupal state.
  $stateOverride = $this->state
    ->get('config_split_use_select');
  if ($stateOverride !== NULL) {

    // Honestly this is probably only useful in tests or if another module
    // comes along and does what chosen or select2 do.
    return (bool) $stateOverride;
  }

  // Modules make the select widget useful.
  foreach ([
    'chosen',
    'select2_all',
  ] as $module) {
    if ($this->moduleHandler
      ->moduleExists($module)) {
      return TRUE;
    }
  }

  // Fall back to checkboxes.
  return FALSE;
}