Drupal 8  8.0.2
EntityFormDisplay Class Reference
Inheritance diagram for EntityFormDisplay:

Public Member Functions

 __construct (array $values, $entity_type)
 
 getRenderer ($field_name)
 
 buildForm (FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state)
 
 processForm ($element, FormStateInterface $form_state, $form)
 
 extractFormValues (FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state)
 
 flagWidgetsErrorsFromViolations (EntityConstraintViolationListInterface $violations, array &$form, FormStateInterface $form_state)
 
 getPluginCollections ()
 
- Public Member Functions inherited from EntityDisplayBase
 __construct (array $values, $entity_type)
 
 getTargetEntityTypeId ()
 
 getMode ()
 
 getOriginalMode ()
 
 getTargetBundle ()
 
 setTargetBundle ($bundle)
 
 id ()
 
 preSave (EntityStorageInterface $storage, $update=TRUE)
 
 calculateDependencies ()
 
 toArray ()
 
 createCopy ($mode)
 
 getComponents ()
 
 getComponent ($name)
 
 setComponent ($name, array $options=array())
 
 removeComponent ($name)
 
 getHighestWeight ()
 
 onDependencyRemoval (array $dependencies)
 
 __sleep ()
 
 __wakeup ()
 
- Public Member Functions inherited from ConfigEntityBase
 __construct (array $values, $entity_type)
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 isNew ()
 
 get ($property_name)
 
 set ($property_name, $value)
 
 enable ()
 
 disable ()
 
 setStatus ($status)
 
 status ()
 
 setSyncing ($syncing)
 
 isSyncing ()
 
 setUninstalling ($uninstalling)
 
 isUninstalling ()
 
 createDuplicate ()
 
 preSave (EntityStorageInterface $storage)
 
 calculateDependencies ()
 
 urlInfo ($rel= 'edit-form', array $options=[])
 
 url ($rel= 'edit-form', $options=array())
 
 link ($text=NULL, $rel= 'edit-form', array $options=[])
 
 toUrl ($rel= 'edit-form', array $options=[])
 
 getCacheTagsToInvalidate ()
 
 getDependencies ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
 onDependencyRemoval (array $dependencies)
 
 setThirdPartySetting ($module, $key, $value)
 
 getThirdPartySetting ($module, $key, $default=NULL)
 
 getThirdPartySettings ($module)
 
 unsetThirdPartySetting ($module, $key)
 
 getThirdPartyProviders ()
 
 isInstallable ()
 
 trustData ()
 
 hasTrustedData ()
 
 save ()
 
- Public Member Functions inherited from Entity
 __construct (array $values, $entity_type)
 
 id ()
 
 uuid ()
 
 isNew ()
 
 enforceIsNew ($value=TRUE)
 
 getEntityTypeId ()
 
 bundle ()
 
 label ()
 
 urlInfo ($rel= 'canonical', array $options=[])
 
 toUrl ($rel= 'canonical', array $options=[])
 
 hasLinkTemplate ($rel)
 
 link ($text=NULL, $rel= 'canonical', array $options=[])
 
 toLink ($text=NULL, $rel= 'canonical', array $options=[])
 
 url ($rel= 'canonical', $options=array())
 
 uriRelationships ()
 
 access ($operation, AccountInterface $account=NULL, $return_as_object=FALSE)
 
 language ()
 
 save ()
 
 delete ()
 
 createDuplicate ()
 
 getEntityType ()
 
 preSave (EntityStorageInterface $storage)
 
 postSave (EntityStorageInterface $storage, $update=TRUE)
 
 postCreate (EntityStorageInterface $storage)
 
 referencedEntities ()
 
 getCacheContexts ()
 
 getCacheTagsToInvalidate ()
 
 getCacheTags ()
 
 getCacheMaxAge ()
 
 getOriginalId ()
 
 setOriginalId ($id)
 
 toArray ()
 
 getTypedData ()
 
 __sleep ()
 
 getConfigDependencyKey ()
 
 getConfigDependencyName ()
 
 getConfigTarget ()
 
- Public Member Functions inherited from RefinableCacheableDependencyInterface
 addCacheContexts (array $cache_contexts)
 
 addCacheTags (array $cache_tags)
 
 mergeCacheMaxAge ($max_age)
 
 addCacheableDependency ($other_object)
 
- Public Member Functions inherited from EntityFormDisplayInterface
 validateFormValues (FieldableEntityInterface $entity, array &$form, FormStateInterface $form_state)
 

Static Public Member Functions

static collectRenderDisplay (FieldableEntityInterface $entity, $form_mode)
 
- Static Public Member Functions inherited from ConfigEntityBase
static sort (ConfigEntityInterface $a, ConfigEntityInterface $b)
 
- Static Public Member Functions inherited from Entity
static preCreate (EntityStorageInterface $storage, array &$values)
 
static preDelete (EntityStorageInterface $storage, array $entities)
 
static postDelete (EntityStorageInterface $storage, array $entities)
 
static postLoad (EntityStorageInterface $storage, array &$entities)
 
static load ($id)
 
static loadMultiple (array $ids=NULL)
 
static create (array $values=array())
 

Protected Attributes

 $displayContext = 'form'
 
- Protected Attributes inherited from EntityDisplayBase
 $id
 
 $targetEntityType
 
 $bundle
 
 $fieldDefinitions
 
 $mode = self::CUSTOM_MODE
 
 $status
 
 $content = array()
 
 $hidden = array()
 
 $originalMode
 
 $plugins = array()
 
 $displayContext
 
 $pluginManager
 
 $renderer
 
- Protected Attributes inherited from ConfigEntityBase
 $originalId
 
 $pluginConfigKey
 
 $status = TRUE
 
 $uuid
 
 $langcode = 'en'
 
 $third_party_settings = array()
 
 $_core = []
 
 $trustedData = FALSE
 
- Protected Attributes inherited from Entity
 $entityTypeId
 
 $enforceIsNew
 
 $typedData
 

Additional Inherited Members

- Data Fields inherited from EntityDisplayBase
const CUSTOM_MODE = '_custom'
 
- Protected Member Functions inherited from EntityDisplayBase
 init ()
 
 getFieldDefinition ($field_name)
 
 getFieldDefinitions ()
 
 getPluginRemovedDependencies (array $plugin_dependencies, array $removed_dependencies)
 
 getLogger ()
 
- Protected Member Functions inherited from ConfigEntityBase
 getTypedConfig ()
 
 addDependency ($type, $name)
 
 invalidateTagsOnSave ($update)
 
- Protected Member Functions inherited from Entity
 entityManager ()
 
 entityTypeManager ()
 
 languageManager ()
 
 uuidGenerator ()
 
 linkTemplates ()
 
 urlRouteParameters ($rel)
 
 invalidateTagsOnSave ($update)
 
- Static Protected Member Functions inherited from ConfigEntityBase
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 
static getConfigManager ()
 
- Static Protected Member Functions inherited from Entity
static invalidateTagsOnDelete (EntityTypeInterface $entity_type, array $entities)
 

Detailed Description

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

( id = "entity_form_display", label = ("Entity form display"), entity_keys = { "id" = "id", "status" = "status" }, config_export = { "id", "targetEntityType", "bundle", "mode", "content", "hidden", } )

Constructor & Destructor Documentation

__construct ( array  $values,
  $entity_type 
)

{}

References Drupal\service().

Here is the call graph for this function:

Member Function Documentation

buildForm ( FieldableEntityInterface  $entity,
array &  $form,
FormStateInterface  $form_state 
)

{Adds field widgets to an entity form.The form elements for the entity's fields are added by reference as direct children in the $form parameter. This parameter can be a full form structure (most common case for entity edit forms), or a sub-element of a larger form.By default, submitted field values appear at the top-level of $form_state->getValues(). A different location within $form_state->getValues() can be specified by setting the '#parents' property on the incoming $form parameter. Because of name clashes, two instances of the same field cannot appear within the same $form element, or within the same '#parents' space.Sample resulting structure in $form:

'#parents' => The location of field values in $form_state->getValues(),
'#entity_type' => The name of the entity type,
'#bundle' => The name of the bundle,
// One sub-array per field appearing in the entity, keyed by field name.
// The structure of the array differs slightly depending on whether the
// widget is 'single-value' (provides the input for one field value,
// most common case), and will therefore be repeated as many times as
// needed, or 'multiple-values' (one single widget allows the input of
// several values; e.g., checkboxes, select box, etc.).
'field_foo' => array(
'#access' => TRUE if the current user has 'edit' grants for the field,
FALSE if not.
'widget' => array(
'#field_name' => The name of the field,
'#title' => The label of the field,
'#description' => The description text for the field,
'#required' => Whether or not the field is required,
'#field_parents' => The 'parents' space for the field in the form,
equal to the #parents property of the $form parameter received by
this method,
// For 'multiple-value' widgets, the remaining elements in the
// sub-array depend on the widget.
// For 'single-value' widgets:
'#theme' => 'field_multiple_value_form',
'#cardinality' => The field cardinality,
'#cardinality_multiple => TRUE if the field can contain multiple
items, FALSE otherwise.
// One sub-array per copy of the widget, keyed by delta.
0 => array(
'#title' => The title to be displayed by the widget,
'#description' => The description text for the field,
'#required' => Whether the widget should be marked required,
'#delta' => 0,
'#weight' => 0,
'#field_parents' => Same as above,
// The remaining elements in the sub-array depend on the widget.
...
),
1 => array(
...
),
...
),
...
),
)
Additionally, some processing data is placed in $form_state, and can be accessed by ::getWidgetState() and ::setWidgetState().
Parameters
\Drupal\Core\Entity\FieldableEntityInterface$entityThe entity.
array$formThe form structure to fill in. This can be a full form structure, or a sub-element of a larger form. The #parents property can be set to control the location of submitted field values within $form_state->getValues(). If not specified, $form['#parents'] is set to an empty array, which results in field values located at the top-level of $form_state->getValues().
\Drupal\Core\Form\FormStateInterface$form_stateThe form state.
}

Implements EntityFormDisplayInterface.

References FieldableEntityInterface\get(), EntityDisplayBase\getComponents(), EntityDisplayBase\getFieldDefinition(), and EntityFormDisplay\getRenderer().

Here is the call graph for this function:

static collectRenderDisplay ( FieldableEntityInterface  $entity,
  $form_mode 
)
static

Returns the entity_form_display object used to build an entity form.

Depending on the configuration of the form mode for the entity bundle, this can be either the display object associated with the form mode, or the 'default' display.

This method should only be used internally when rendering an entity form. When assigning suggested display options for a component in a given form mode, entity_get_form_display() should be used instead, in order to avoid inadvertently modifying the output of other form modes that might happen to use the 'default' display too. Those options will then be effectively applied only if the form mode is configured to use them.

hook_entity_form_display_alter() is invoked on each display, allowing 3rd party code to alter the display options held in the display before they are used to generate render arrays.

Parameters
\Drupal\Core\Entity\FieldableEntityInterface$entityThe entity for which the form is being built.
string$form_modeThe form mode.
Returns
The display object that should be used to build the entity form.
See Also
entity_get_form_display()
hook_entity_form_display_alter()

References EntityInterface\bundle(), Drupal\entityManager(), Drupal\entityQuery(), EntityInterface\getEntityTypeId(), and Drupal\moduleHandler().

Referenced by NestedEntityTestForm\buildForm(), QuickEditFieldForm\init(), and ContentEntityForm\init().

Here is the call graph for this function:

Here is the caller graph for this function:

extractFormValues ( FieldableEntityInterface  $entity,
array &  $form,
FormStateInterface  $form_state 
)

{Extracts field values from the submitted widget values into the entity.This accounts for drag-and-drop reordering of field values, and filtering of empty values.

Parameters
\Drupal\Core\Entity\FieldableEntityInterface$entityThe entity.
array$formThe form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state.
Returns
array An array whose keys and values are the keys of the top-level entries in $form_state->getValues() that have been processed. The remaining entries, if any, do not correspond to widgets and should be extracted manually by the caller if needed.
}

Implements EntityFormDisplayInterface.

References EntityFormDisplay\getRenderer().

Here is the call graph for this function:

flagWidgetsErrorsFromViolations ( EntityConstraintViolationListInterface  $violations,
array &  $form,
FormStateInterface  $form_state 
)

{Flags entity validation violations as form errors.This method processes all violations passed, thus any violations not related to fields of the form display must be processed before this method is invoked.The method flags constraint violations related to fields shown on the form as form errors on the correct form elements. Possibly pre-existing violations of hidden fields (so fields not appearing in the display) are ignored. Other, non-field related violations are passed through and set as form errors according to the property path of the violations.

Parameters
\Drupal\Core\Entity\EntityConstraintViolationListInterface$violationsThe violations to flag.
array$formThe form structure where field elements are attached to. This might be a full form structure, or a sub-element of a larger form.
\Drupal\Core\Form\FormStateInterface$form_stateThe form state.
}

Implements EntityFormDisplayInterface.

References FieldableEntityInterface\get(), EntityConstraintViolationListInterface\getByField(), EntityConstraintViolationListInterface\getEntity(), EntityConstraintViolationListInterface\getFieldNames(), and EntityFormDisplay\getRenderer().

Here is the call graph for this function:

getPluginCollections ( )

{Gets the plugin collections used by this entity.

Returns
[] An array of plugin collections, keyed by the property name they use to store their configuration.
}

Implements EntityWithPluginCollectionInterface.

References EntityDisplayBase\getComponents(), and EntityDisplayBase\getFieldDefinition().

Here is the call graph for this function:

getRenderer (   $field_name)

{Gets the renderer plugin for a field (e.g. widget, formatter).

Parameters
string$field_nameThe field name.
Returns
|null A widget or formatter plugin or NULL if the field does not exist.
}

Implements EntityDisplayInterface.

References EntityDisplayBase\getComponent(), and EntityDisplayBase\getFieldDefinition().

Referenced by EntityFormDisplay\buildForm(), EntityFormDisplay\extractFormValues(), and EntityFormDisplay\flagWidgetsErrorsFromViolations().

Here is the call graph for this function:

Here is the caller graph for this function:

processForm (   $element,
FormStateInterface  $form_state,
  $form 
)

Process callback: assigns weights and hides extra fields.

See Also
::buildForm()

References Entity\bundle(), Drupal\entityManager(), EntityDisplayBase\getComponent(), and EntityDisplayBase\getComponents().

Here is the call graph for this function:

Field Documentation

$displayContext = 'form'
protected

{}


The documentation for this class was generated from the following file: