Integrations
Field Mapping
Map form fields to integration fields with transformations.
The Field Mapping system maps form submission fields to integration-specific fields, with optional transformations.
How It Works
- Users configure mappings in the UI:
form_field -> integration_field - Optional transformations are applied during mapping
- Static values can be injected into the payload
- The
FieldMapperservice processes submission data and outputs integration-ready payloads
Transformations
| Transformation | Description | Example |
|---|---|---|
none | Pass through unchanged | "Hello" -> "Hello" |
uppercase | Convert to uppercase | "hello" -> "HELLO" |
lowercase | Convert to lowercase | "HELLO" -> "hello" |
trim | Remove leading/trailing whitespace | " hello " -> "hello" |
date_iso | ISO 8601 date format | "Jan 15, 2025" -> "2025-01-15T00:00:00+00:00" |
date_us | US date format | "2025-01-15" -> "01/15/2025" |
boolean | Convert to boolean | "1" -> true |
number | Convert to float | "42.5" -> 42.5 |
integer | Convert to integer | "42.5" -> 42 |
string | Convert to string | 42 -> "42" |
json | Convert to JSON string | ["a", "b"] -> '["a","b"]' |
comma_separated | Join array with commas | ["a", "b"] -> "a, b" |
first_item | First element of array | ["a", "b"] -> "a" |
last_item | Last element of array | ["a", "b"] -> "b" |
count | Count items or string length | ["a", "b"] -> 2 |
Configuration DTO
Field mappings are represented by the FieldMappingData DTO:
use FilaForms\Integrations\Data\FieldMappingData;
$mapping = FieldMappingData::from([
'fieldMappings' => [
'name_field' => 'contact_name',
'email_field' => 'email_address',
],
'transformations' => [
'email_field' => 'lowercase',
'name_field' => 'trim',
],
'staticValues' => [
'source' => 'web_form',
'campaign' => 'summer_2025',
],
'includeUnmappedFields' => false,
]);
Using the FieldMapper Service
use FilaForms\Integrations\Services\FieldMapper;
$mapper = app(FieldMapper::class);
$submissionData = [
'name_field' => ' Jane Doe ',
'email_field' => 'JANE@EXAMPLE.COM',
'phone_field' => '555-1234',
];
$result = $mapper->map($submissionData, $mapping);
// Result:
// [
// 'contact_name' => 'Jane Doe',
// 'email_address' => 'jane@example.com',
// 'source' => 'web_form',
// 'campaign' => 'summer_2025',
// ]
The phone_field is excluded because it has no mapping defined and includeUnmappedFields is false.
Nested Field Support
Both input and output fields support dot notation for nested data:
$mapping = FieldMappingData::from([
'fieldMappings' => [
'address.city' => 'location.city_name',
'address.zip' => 'location.postal_code',
],
]);