public function deleteSuperTableField(SuperTableField $supertableField): bool
    {
        // Clear the schema cache
        $db = Craft::$app->getDb();
        $db->getSchema()->refresh();

        $transaction = $db->beginTransaction();
        try {
            $originalContentTable = Craft::$app->getContent()->contentTable;
            Craft::$app->getContent()->contentTable = $supertableField->contentTable;

            // Delete the block types
            $blockTypes = $this->getBlockTypesByFieldId($supertableField->id);

            foreach ($blockTypes as $blockType) {
                $this->deleteBlockType($blockType);
            }

            // Drop the content table
            $db->createCommand()
                ->dropTable($supertableField->contentTable)
                ->execute();

            Craft::$app->getContent()->contentTable = $originalContentTable;

            $transaction->commit();

            return true;
        } catch (\Throwable $e) {
            $transaction->rollBack();

            throw $e;
        }
    }
public function deleteSuperTableField(SuperTableField $supertableField): bool
    {
        // Clear the schema cache
        $db = Craft::$app->getDb();
        $db->getSchema()->refresh();

        $transaction = $db->beginTransaction();
        try {
            $originalContentTable = Craft::$app->getContent()->contentTable;
            Craft::$app->getContent()->contentTable = $supertableField->contentTable;

            // Delete the block types
            $blockTypes = $this->getBlockTypesByFieldId($supertableField->id);

            foreach ($blockTypes as $blockType) {
                $this->deleteBlockType($blockType);
            }

            // Drop the content table
            $db->createCommand()
                ->dropTable($supertableField->contentTable)
                ->execute();

            Craft::$app->getContent()->contentTable = $originalContentTable;

            $transaction->commit();

            return true;
        } catch (\Throwable $e) {
            $transaction->rollBack();

            throw $e;
        }
    }
public function deleteSuperTableField ( SuperTableField $ supertableField ) : bool { // Clear the schema cache $ db = Craft :: $ app -> getDb ( ) ; $ db -> getSchema ( ) -> refresh ( ) ; $ transaction = $ db -> beginTransaction ( ) ; try { $ originalContentTable = Craft :: $ app -> getContent ( ) -> contentTable ; Craft :: $ app -> getContent ( ) -> contentTable = $ supertableField -> contentTable ; // Delete the block types $ blockTypes = $ this -> getBlockTypesByFieldId ( $ supertableField -> id ) ; foreach ( $ blockTypes as $ blockType ) { $ this -> deleteBlockType ( $ blockType ) ; } // Drop the content table $ db -> createCommand ( ) -> dropTable ( $ supertableField -> contentTable ) -> execute ( ) ; Craft :: $ app -> getContent ( ) -> contentTable = $ originalContentTable ; $ transaction -> commit ( ) ; return true ; } catch ( \ Throwable $ e ) { $ transaction -> rollBack ( ) ; throw $ e ; } }
Deletes a Super Table field.

@param SuperTableField $supertableField The Super Table field.

@return bool Whether the field was deleted successfully.
@throws \Throwable
Deletes a Super Table field .