You are here

function lightning_layout_field_widget_form_alter in Lightning Layout 8.2

Implements hook_field_widget_form_alter().

File

./lightning_layout.module, line 121
Contains layout functionality for Lightning.

Code

function lightning_layout_field_widget_form_alter(&$element, FormStateInterface &$form_state, $context) {
  $items = isset($context['items']) ? $context['items'] : NULL;

  // Hide the Layout field's select widget if it only has the default "none"
  // option.
  if ($items instanceof EntityReferenceFieldItemListInterface && $items
    ->getName() === 'layout_selection' && isset($element['#type']) && $element['#type'] === 'select' && count($element['#options']) === 1) {
    $element['#access'] = FALSE;
  }
}