public property FieldInstance::$default_value

Default field value.

The default value is used when an entity is created, either:

  • through an entity creation form; the form elements for the field are prepopulated with the default value.
  • through direct API calls (i.e. $entity->save()); the default value is added if the $entity object provides no explicit entry (actual values or "the field is empty") for the field.

The default value is expressed as a numerically indexed array of items, each item being an array of key/value pairs matching the set of 'columns' defined by the "field schema" for the field type, as exposed in hook_field_schema(). If the number of items exceeds the cardinality of the field, extraneous items will be ignored.

This property is overlooked if the $default_value_function is non-empty.

Example for a number_integer field:

array(
  array(
    'value' => 1,
  ),
  array(
    'value' => 2,
  ),
);

Type: array

File

drupal/core/modules/field/lib/Drupal/field/Plugin/Core/Entity/FieldInstance.php, line 150
Contains \Drupal\field\Plugin\Core\Entity\FieldInstance.

Class

FieldInstance
Defines the Field instance entity.

Namespace

Drupal\field\Plugin\Core\Entity

Code

public $default_value = array();