You are here

SocialPrivateMessageEntityAutocomplete.php in Open Social 8.2

File

modules/social_features/social_private_message/src/Element/SocialPrivateMessageEntityAutocomplete.php
View source
<?php

namespace Drupal\social_private_message\Element;

use Drupal\Core\Form\FormStateInterface;
use Drupal\social_core\Entity\Element\EntityAutocomplete;

/**
 * Provides an private message member autocomplete form element.
 *
 * The #default_value accepted by this element is either an entity object or an
 * array of entity objects.
 *
 * @FormElement("social_private_message_entity_autocomplete")
 */
class SocialPrivateMessageEntityAutocomplete extends EntityAutocomplete {

  /**
   * Form element validation handler for entity_autocomplete elements.
   */
  public static function validateEntityAutocomplete(array &$element, FormStateInterface $form_state, array &$complete_form) {
    parent::validateEntityAutocomplete($element, $form_state, $complete_form);
    $value = $form_state
      ->getValue('members');
    $form_state
      ->setValue('members', $value['target_id']);
  }

}

Classes

Namesort descending Description
SocialPrivateMessageEntityAutocomplete Provides an private message member autocomplete form element.