Skip to main content

Export Types

Extend Freeform Exporting capabilities by adding your own export types:

Registering Custom Export Types

Use this event to attach your own export types.

First, create your own export type, which extends the Export Interface:

<?php

namespace My\Exporter;

use Solspace\Freeform\Library\Export\ExportInterface;
use Solspace\Freeform\Form\Form;

class CustomExport implements ExportInterface
{
private $submissionData;

public function __construct(Form $form, array $submissionData)
{
$this->submissionData = $submissionData;
}

public static function getLabel(): string
{
return 'Custom Export';
}

public function getMimeType(): string
{
return 'text/html';
}

public function getFileExtension(): string
{
return 'html';
}

public function export()
{
return '<html><body><pre>'.json_encode($this->submissionData).'</pre></body></html>';
}
}

Then register your exporter:

use Solspace\Freeform\Services\ExportProfilesService;
use Solspace\Freeform\Events\ExportProfiles\RegisterExporterEvent;
use My\Exporter\CustomExport;

Event::on(
ExportProfilesService::class,
ExportProfilesService::EVENT_REGISTER_EXPORTER,
function (RegisterExporterEvent $event) {
$event->addExporter(
'custom_export',
CustomExport::class
);
}
);

You should now see your custom export type available in the export profiles view and in the quick export pop-up.