function FieldItemBase::setValue

Same name and namespace in other branches
  1. 11.x core/lib/Drupal/Core/Field/FieldItemBase.php \Drupal\Core\Field\FieldItemBase::setValue()
1 call to FieldItemBase::setValue()
CreatedItem::applyDefaultValue in core/lib/Drupal/Core/Field/Plugin/Field/FieldType/CreatedItem.php
Applies the default value.

File

core/lib/Drupal/Core/Field/FieldItemBase.php, line 104

Class

FieldItemBase
An entity field item.

Namespace

Drupal\Core\Field

Code

public function setValue($values, $notify = TRUE) {
  // Treat the values as property value of the first property, if no array is
  // given.
  if (isset($values) && !is_array($values)) {
    $keys = array_keys($this->definition
      ->getPropertyDefinitions());
    $values = [
      $keys[0] => $values,
    ];
  }
  parent::setValue($values, $notify);
}

Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.