You are here

function domain_entity_field_widget_form_alter in Domain Access Entity 8

Implements hook_field_widget_form_alter().

File

./domain_entity.module, line 574
Enables domain access for entities, and access query alter.

Code

function domain_entity_field_widget_form_alter(&$element, FormStateInterface $form_state, $context) {
  if ($context['items']
    ->getFieldDefinition()
    ->getName() !== DomainEntityMapper::FIELD_NAME) {
    return;
  }

  // Make affiliate domain selection required in case if user
  // have no "publish to any domain" permission to avoid ambiguity.
  $element['#required'] = !\Drupal::currentUser()
    ->hasPermission('publish to any domain');
}