->
save();
FieldConfig::
create([ 'entity_type' =>
static::
$entityTypeId,
'field_name' => 'field_rest_test_multivalue',
'bundle' =>
$this->entity->
bundle(),
]) ->
setLabel('Test field: multi-value'
) ->
setTranslatable(FALSE
) ->
save();
// Reload entity so that it has the new field.
$reloaded_entity =
$this->entityStorage->
loadUnchanged($this->entity->
id());
// Some entity types are not stored, hence they cannot be reloaded.
if ($reloaded_entity !== NULL
) { $this->entity =
$reloaded_entity;
// Set a default value on the fields.
$this->entity->
set('field_rest_test',
['value' => 'All the faith they had had had had no effect on the outcome of their life.'
]);
$this->entity->
set('field_rest_test_multivalue',
[['value' => 'One'
],
['value' => 'Two'
]]);
$this->entity->
set('rest_test_validation',
['value' => 'allowed value'
]);
$this->entity->
save();
} } }