I have a matrix field set up as global (strategies).

Inside each matrix block there is a SuperTable (pairs)

On each row in the SuperTable there is a lightswitch (active)

I need to toggle the lightswitch programatically for each row.

Looking at the SuperTable and Craft docs, I still can't make heads or tails of this. Can anyone help?


Ended up with a poor man's solution by going directly to the table and editing the column. Would still love to know how to do this "properly, though.

$disable = StcThreePairs::find()
    ->where(['elementId' => $pair->id])

$disable->field_active = 0;

So you'll want to update the Super Table Block's content and to do that when in a Matrix field is a little tricky, but it can be done.

$matrixBlocks = $entry->matrixField->all();

foreach ($matrixBlocks as $matrixBlock) {
    $superTableBlocks = $matrixBlock->superTableField->all();

    foreach ($superTableBlocks as $superTableBlock) {
        $superTableBlock->setFieldValues(['lightswitchField' => true]);


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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