I am trying to add new lines into a SuperTable field of an entry from my plugin. Following the Developper sample, I am able to change set lines to this SuperTable field. But it is replacing the existing content. What should I do to be able to keep existing lines in my SuperTable and add new ones? Thanks for your help!

1 Answer 1


Got it!

In case you just want to add lines (or Blocks) to a SuperTable field of an entry, no need to update the entry itself, you "just" have to create new Blocks with correct type, field and entry.

    $field = craft()->fields->getFieldByHandle('mySuperTableField');
    $blockTypes = craft()->superTable->getBlockTypesByFieldId($field->id);
    $blockType = $blockTypes[0]; //Only 1 Type of Blocks in the SuperTable
    $typeId = $blockType['id'];

    $block = new SuperTable_BlockModel();
    $block->fieldId = $field->id;
    $block->typeId = $typeId;
    $block->ownerId = $entryId; //this is the entry id

        'categoryOne' => [$catOne->id],
        'categoryTwo' => [$catTwo->id],
        'textField' => 'blablable...'

    $success = craft()->superTable->saveBlock($block);

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.