1

I want to save a supertable with different infos on two different siteId of an entry. It works fine with all the other fields i'm using: the value is saved separately to each different language. But with the supertable, the info is saved, but it overrides both languages with the new info.. Is there a parameter we need to add or something? I'm using this:

$field = Craft::$app->getFields()->getFieldByHandle($handle);
    $blockTypes = SuperTable::$plugin->getService()->getBlockTypesByFieldId($field->id);
    $blockType = $blockTypes[0];

    $superTableData['new1'] = [
        'type' => $blockType->id,
        'enabled' => true,
        'fields' => [
           'field1' => 'value',
           'field2' => 'value',
         ]
    ];

thanks!

2 Answers 2

1

Usually, site association for elements is controlled using the $siteId property. Try this:

$superTableData['new1'] = [
    'type' => $blockType->id,
    'enabled' => true,
    'siteId' => 123, // replace with your site ID
    'fields' => [
       'field1' => 'value',
       'field2' => 'value',
    ]
];
1
  • yeah I tried, it doesn't work unfortunately.
    – Martin288
    Jul 28, 2021 at 13:32
1

So it seems like the short answer is: you can't.

First you have to create the entry and superTable to the default site and it copies the data to every site.

Then you need to update the entry WITH siteId of other site and update the supertable.

That's the way that worked for me!

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.