- last update
over 1 year ago 195 pass
I ran into some problems when trying to set the format of a text field inside an entity_generate plugin.
...
'default_values' => [
'field_description/format' => 'basic_html',
'field_specifications/format' => 'basic_html',
],
...
This wasn't working, which I thought was weird, since I could use array structure inside the 'values' configuration.
// Gather any static default values for properties/fields.
if (isset($this->configuration['default_values']) && is_array($this->configuration['default_values'])) {
foreach ($this->configuration['default_values'] as $key => $value) {
$entity_values[$key] = $value;
}
}
So my previous example was being processed as:
'field_description/format' => 'basic_html',
'field_specifications/format' => 'basic_html',
Instead of the expected
'field_description' => [
'format' => 'basic_html',
],
'field_specifications' => [
'format' => 'basic_html',
],
It should be using the same logic as the 'value', using NestedArray and separating it by the property separator '/':
NestedArray::setValue($entity_values, explode(Row::PROPERTY_SEPARATOR, $key), $source_value, TRUE);
Needs work
5.0
Plugins
The change is currently missing an automated test that fails when run with the original code, and succeeds when the bug has been fixed.
Not all content is available!
It's likely this issue predates Contrib.social: some issue and comment data are missing.