How can i save a block_field field programmatically?

Created on 12 December 2018, over 6 years ago

Hi,
could anyone help me please, how can i save a block_field field programmatically?

💬 Support request
Status

Active

Version

1.0

Component

Miscellaneous

Created by

🇭🇺Hungary chrispooh

Live updates comments and jobs are added and updated live.
Sign in to follow issues

Comments & Activities

Not all content is available!

It's likely this issue predates Contrib.social: some issue and comment data are missing.

  • 🇨🇦Canada JFKiwad Montreal

    7 years later! In case you need to do it, heres what's in their test code :

    // Create a referencing entity.
    $referencing_entity = $this->container->get('entity_type.manager')
    ->getStorage('entity_test')
    ->create(['name' => $this->randomMachineName()]);

    $referencing_entity->field_test->plugin_id = 'block_field_test_access';
    $referencing_entity->field_test->settings = [
    'label' => 'Custom access.',
    'label_display' => TRUE,
    'access' => TRUE,
    ];
    $referencing_entity->save();

Production build 0.71.5 2024