You are here

protected function EntityFormField::getPluginApplicableOptions in Views Entity Form Field 8

Returns an array of applicable widget options for a field.

Parameters

\Drupal\Core\Field\FieldDefinitionInterface $field_definition: The field definition.

Return value

string[] An array of applicable widget options.

1 call to EntityFormField::getPluginApplicableOptions()
EntityFormField::buildOptionsForm in src/Plugin/views/field/EntityFormField.php
Default options form that provides the label widget that all fields should have.

File

src/Plugin/views/field/EntityFormField.php, line 188

Class

EntityFormField
Defines a views form element for an entity field widget.

Namespace

Drupal\views_entity_form_field\Plugin\views\field

Code

protected function getPluginApplicableOptions(FieldDefinitionInterface $field_definition) {
  $options = $this->fieldWidgetManager
    ->getOptions($field_definition
    ->getType());
  $applicable_options = [];
  foreach ($options as $option => $label) {
    $plugin_class = DefaultFactory::getPluginClass($option, $this->fieldWidgetManager
      ->getDefinition($option));
    if ($plugin_class::isApplicable($field_definition)) {
      $applicable_options[$option] = $label;
    }
  }
  return $applicable_options;
}