class EntityFormDisplay

Configuration entity that contains widget options for all components of a entity form in a given form mode.

Plugin annotation


@EntityType(
  id = "entity_form_display",
  label = @Translation("Entity form display"),
  module = "entity",
  controllers = {
    "storage" = "Drupal\Core\Config\Entity\ConfigStorageController"
  },
  config_prefix = "entity.form_display",
  entity_keys = {
    "id" = "id",
    "uuid" = "uuid"
  }
)

Hierarchy

Expanded class hierarchy of EntityFormDisplay

2 files declare their use of EntityFormDisplay
entity_test.module in drupal/core/modules/system/tests/modules/entity_test/entity_test.module
Test module for the entity API providing several entity types for testing.
field.attach.inc in drupal/core/modules/field/field.attach.inc
Field attach API, allowing entities (nodes, users, ...) to be 'fieldable'.

File

drupal/core/modules/entity/lib/Drupal/entity/Plugin/Core/Entity/EntityFormDisplay.php, line 33
Contains \Drupal\entity\Plugin\Core\Entity\EntityFormDisplay.

Namespace

Drupal\entity\Plugin\Core\Entity
View source
class EntityFormDisplay extends EntityDisplayBase implements EntityFormDisplayInterface, \Serializable {

  /**
   * {@inheritdoc}
   */
  public function __construct(array $values, $entity_type) {
    $this->pluginManager = \Drupal::service('plugin.manager.field.widget');
    $this->displayContext = 'form';
    parent::__construct($values, $entity_type);
  }

  /**
   * {@inheritdoc}
   */
  public function getWidget($field_name) {
    if (isset($this->plugins[$field_name])) {
      return $this->plugins[$field_name];
    }

    // Instantiate the widget object from the stored display properties.
    if ($configuration = $this
      ->getComponent($field_name)) {
      $instance = field_info_instance($this->targetEntityType, $field_name, $this->bundle);
      $widget = $this->pluginManager
        ->getInstance(array(
        'instance' => $instance,
        'form_mode' => $this->originalMode,
        // No need to prepare, defaults have been merged in setComponent().
        'prepare' => FALSE,
        'configuration' => $configuration,
      ));
    }
    else {
      $widget = NULL;
    }

    // Persist the widget object.
    $this->plugins[$field_name] = $widget;
    return $widget;
  }

  /**
   * {@inheritdoc}
   */
  public function serialize() {

    // Only store the definition, not external objects or derived data.
    $data = $this
      ->getExportProperties() + array(
      'entityType' => $this
        ->entityType(),
    );
    return serialize($data);
  }

  /**
   * {@inheritdoc}
   */
  public function unserialize($serialized) {
    $data = unserialize($serialized);
    $entity_type = $data['entityType'];
    unset($data['entityType']);
    $this
      ->__construct($data, $entity_type);
  }

}

Members

Namesort descending Modifiers Type Description Overrides
ConfigEntityBase::$originalID protected property The original ID of the configuration entity.
ConfigEntityBase::$status public property The enabled/disabled status of the configuration entity. 1
ConfigEntityBase::createDuplicate public function Overrides Entity::createDuplicate(). Overrides Entity::createDuplicate 2
ConfigEntityBase::disable public function Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::disable(). Overrides ConfigEntityInterface::disable 1
ConfigEntityBase::enable public function Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::enable(). Overrides ConfigEntityInterface::enable
ConfigEntityBase::get public function Overrides Entity::get(). Overrides Entity::get 2
ConfigEntityBase::getOriginalID public function Implements ConfigEntityInterface::getOriginalID(). Overrides ConfigEntityInterface::getOriginalID
ConfigEntityBase::isNew public function Overrides Entity::isNew(). Overrides Entity::isNew
ConfigEntityBase::set public function Overrides Entity::set(). Overrides Entity::set
ConfigEntityBase::setOriginalID public function Implements ConfigEntityInterface::setOriginalID(). Overrides ConfigEntityInterface::setOriginalID
ConfigEntityBase::setStatus public function Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::setStatus(). Overrides ConfigEntityInterface::setStatus
ConfigEntityBase::sort public static function Helper callback for uasort() to sort configuration entities by weight and label. 2
ConfigEntityBase::status public function Implements \Drupal\Core\Config\Entity\ConfigEntityInterface::status(). Overrides ConfigEntityInterface::status 1
Entity::$enforceIsNew protected property Boolean indicating whether the entity should be forced to be new.
Entity::$entityType protected property The entity type.
Entity::$isDefaultRevision protected property Indicates whether this is the default revision. 1
Entity::$langcode public property The language code of the entity's default language. 7
Entity::$newRevision protected property Boolean indicating whether a new revision should be created on save.
Entity::access public function Implements \Drupal\Core\TypedData\AccessibleInterface::access(). Overrides AccessibleInterface::access
Entity::bundle public function Implements \Drupal\Core\Entity\EntityInterface::bundle(). Overrides EntityInterface::bundle 4
Entity::delete public function Implements \Drupal\Core\Entity\EntityInterface::delete(). Overrides EntityInterface::delete 3
Entity::enforceIsNew public function Implements \Drupal\Core\Entity\EntityInterface::enforceIsNew(). Overrides EntityInterface::enforceIsNew
Entity::entityInfo public function Implements \Drupal\Core\Entity\EntityInterface::entityInfo(). Overrides EntityInterface::entityInfo
Entity::entityType public function Implements \Drupal\Core\Entity\EntityInterface::entityType(). Overrides EntityInterface::entityType
Entity::getBCEntity public function Implements \Drupal\Core\Entity\EntityInterface::getBCEntity(). Overrides EntityInterface::getBCEntity 1
Entity::getConstraints public function Implements \Drupal\Core\TypedData\TypedDataInterface::getConstraints(). Overrides TypedDataInterface::getConstraints
Entity::getDefinition public function Implements \Drupal\Core\TypedData\TypedDataInterface::getDefinition(). Overrides TypedDataInterface::getDefinition
Entity::getIterator public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getIterator(). 1
Entity::getName public function Implements \Drupal\Core\TypedData\TypedDataInterface::getName(). Overrides TypedDataInterface::getName
Entity::getNGEntity public function Implements \Drupal\Core\Entity\EntityInterface::getNGEntity(). Overrides EntityInterface::getNGEntity
Entity::getParent public function Implements \Drupal\Core\TypedData\TypedDataInterface::getParent(). Overrides TypedDataInterface::getParent
Entity::getProperties public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getProperties(). Overrides ComplexDataInterface::getProperties 1
Entity::getPropertyDefinition public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinition(). Overrides ComplexDataInterface::getPropertyDefinition 1
Entity::getPropertyDefinitions public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyDefinitions(). Overrides ComplexDataInterface::getPropertyDefinitions 1
Entity::getPropertyPath public function Implements \Drupal\Core\TypedData\TypedDataInterface::getPropertyPath(). Overrides TypedDataInterface::getPropertyPath
Entity::getPropertyValues public function Implements \Drupal\Core\TypedData\ComplexDataInterface::getPropertyValues(). Overrides ComplexDataInterface::getPropertyValues 1
Entity::getRevisionId public function Implements \Drupal\Core\Entity\EntityInterface::getRevisionId(). Overrides EntityInterface::getRevisionId 4
Entity::getRoot public function Implements \Drupal\Core\TypedData\TypedDataInterface::getRoot(). Overrides TypedDataInterface::getRoot
Entity::getString public function Implements \Drupal\Core\TypedData\TypedDataInterface::getString(). Overrides TypedDataInterface::getString
Entity::getTranslation public function Implements \Drupal\Core\TypedData\TranslatableInterface::getTranslation(). Overrides TranslatableInterface::getTranslation 1
Entity::getTranslationLanguages public function Implements \Drupal\Core\TypedData\TranslatableInterface::getTranslationLanguages(). Overrides TranslatableInterface::getTranslationLanguages 1
Entity::getType public function Implements \Drupal\Core\TypedData\TypedDataInterface::getType(). Overrides TypedDataInterface::getType 2
Entity::getValue public function Implements \Drupal\Core\TypedData\TypedDataInterface::getValue(). Overrides TypedDataInterface::getValue
Entity::isDefaultRevision public function Implements \Drupal\Core\Entity\EntityInterface::isDefaultRevision(). Overrides EntityInterface::isDefaultRevision 1
Entity::isEmpty public function Implements \Drupal\Core\TypedData\ComplexDataInterface::isEmpty(). Overrides ComplexDataInterface::isEmpty 1
Entity::isNewRevision public function Implements \Drupal\Core\Entity\EntityInterface::isNewRevision(). Overrides EntityInterface::isNewRevision
Entity::isTranslatable public function Implements \Drupal\Core\Entity\EntityInterface::isTranslatable(). Overrides EntityInterface::isTranslatable
Entity::label public function Implements \Drupal\Core\Entity\EntityInterface::label(). Overrides EntityInterface::label 4
Entity::language public function Implements \Drupal\Core\TypedData\TranslatableInterface::language(). Overrides TranslatableInterface::language 1
Entity::onChange public function Implements \Drupal\Core\TypedData\ComplexDataInterface::onChange(). Overrides ComplexDataInterface::onChange
Entity::setContext public function Implements \Drupal\Core\TypedData\TypedDataInterface::setContext(). Overrides TypedDataInterface::setContext
Entity::setNewRevision public function Implements \Drupal\Core\Entity\EntityInterface::setNewRevision(). Overrides EntityInterface::setNewRevision
Entity::setPropertyValues public function Implements \Drupal\Core\TypedData\ComplexDataInterface::setPropertyValues(). Overrides ComplexDataInterface::setPropertyValues 1
Entity::setValue public function Implements \Drupal\Core\TypedData\TypedDataInterface::setValue(). Overrides TypedDataInterface::setValue
Entity::translations public function Returns the languages the entity is translated to. 1
Entity::uri public function Implements \Drupal\Core\Entity\EntityInterface::uri(). Overrides EntityInterface::uri 8
Entity::uriRelationships public function Returns a list of URI relationships supported by this entity. Overrides EntityInterface::uriRelationships
Entity::uuid public function Implements \Drupal\Core\Entity\EntityInterface::uuid(). Overrides EntityInterface::uuid 1
Entity::validate public function Implements \Drupal\Core\TypedData\TypedDataInterface::validate(). Overrides TypedDataInterface::validate 1
EntityDisplayBase::$bundle public property Bundle to be displayed.
EntityDisplayBase::$content protected property List of component display options, keyed by component name.
EntityDisplayBase::$displayContext protected property Context in which this entity will be used (e.g. 'display', 'form').
EntityDisplayBase::$id public property Unique ID for the config entity.
EntityDisplayBase::$mode public property View or form mode to be displayed.
EntityDisplayBase::$originalMode public property The original view or form mode that was requested (case of view/form modes being configured to fall back to the 'default' display).
EntityDisplayBase::$pluginManager protected property The plugin manager used by this entity type.
EntityDisplayBase::$plugins protected property The plugin objects used for this display, keyed by field name.
EntityDisplayBase::$targetEntityType public property Entity type to be displayed.
EntityDisplayBase::$uuid public property Unique UUID for the config entity.
EntityDisplayBase::createCopy public function Creates a duplicate of the EntityDisplay object on a different view mode. Overrides EntityDisplayBaseInterface::createCopy
EntityDisplayBase::getComponent public function Gets the display options set for a component. Overrides EntityDisplayBaseInterface::getComponent
EntityDisplayBase::getComponents public function Gets the display options for all components. Overrides EntityDisplayBaseInterface::getComponents
EntityDisplayBase::getExportProperties public function Overrides \Drupal\Core\Entity\Entity::getExportProperties(). Overrides ConfigEntityBase::getExportProperties
EntityDisplayBase::getHighestWeight public function Returns the highest weight of the components in the display. Overrides EntityDisplayBaseInterface::getHighestWeight
EntityDisplayBase::id public function Implements \Drupal\Core\Entity\EntityInterface::id(). Overrides Entity::id
EntityDisplayBase::removeComponent public function Sets a component to be hidden. Overrides EntityDisplayBaseInterface::removeComponent
EntityDisplayBase::save public function Implements \Drupal\Core\Entity\EntityInterface::save(). Overrides Entity::save
EntityDisplayBase::setComponent public function Sets the display options for a component. Overrides EntityDisplayBaseInterface::setComponent
EntityFormDisplay::getWidget public function Returns the Widget plugin for a field. Overrides EntityFormDisplayInterface::getWidget
EntityFormDisplay::serialize public function
EntityFormDisplay::unserialize public function
EntityFormDisplay::__construct public function Overrides Entity::__construct(). Overrides EntityDisplayBase::__construct