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!
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; //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 $block->setContentFromPost(array( 'categoryOne' => [$catOne->id], 'categoryTwo' => [$catTwo->id], 'textField' => 'blablable...' )); $success = craft()->superTable->saveBlock($block);