function FieldItemList::setValue
Same name in other branches
- 9 core/lib/Drupal/Core/Field/FieldItemList.php \Drupal\Core\Field\FieldItemList::setValue()
- 8.9.x core/lib/Drupal/Core/Field/FieldItemList.php \Drupal\Core\Field\FieldItemList::setValue()
- 10 core/lib/Drupal/Core/Field/FieldItemList.php \Drupal\Core\Field\FieldItemList::setValue()
Overrides ItemList::setValue
3 calls to FieldItemList::setValue()
- FieldItemList::applyDefaultValue in core/
lib/ Drupal/ Core/ Field/ FieldItemList.php - FieldItemList::generateSampleItems in core/
lib/ Drupal/ Core/ Field/ FieldItemList.php - ModerationStateFieldItemList::setValue in core/
modules/ content_moderation/ src/ Plugin/ Field/ ModerationStateFieldItemList.php
File
-
core/
lib/ Drupal/ Core/ Field/ FieldItemList.php, line 101
Class
- FieldItemList
- Represents an entity field; that is, a list of field item objects.
Namespace
Drupal\Core\FieldCode
public function setValue($values, $notify = TRUE) {
// Support passing in only the value of the first item, either as a literal
// (value of the first property) or as an array of properties.
if (isset($values) && (!is_array($values) || !empty($values) && !is_numeric(current(array_keys($values))))) {
$values = [
0 => $values,
];
}
parent::setValue($values, $notify);
}
Buggy or inaccurate documentation? Please file an issue. Need support? Need help programming? Connect with the Drupal community.