submit method

Future<SubmissionModel> submit(
  1. String formPath,
  2. Map<String, dynamic> data
)

Sends a new form submission to the given form path.

formPath is the full path to the form (e.g. '/registration') data is the map of form field values (can be nested from panels/columns).

The data is automatically flattened to match Form.io's expected format where all field values are at the root level.

Throws SubmissionException on error.

Implementation

Future<SubmissionModel> submit(String formPath, Map<String, dynamic> data) async {
  try {
    final url = ApiEndpoints.postSubmission(formPath);
    // Flatten nested data and add required Form.io fields
    final flattenedData = _flattenData(data);
    flattenedData['submit'] = true;

    final response = await client.dio.post(
      url,
      data: {
        'data': flattenedData,
        'state': 'submitted',
      },
    );
    return SubmissionModel.fromJson(response.data ?? {});
  } catch (e) {
    throw SubmissionException('Failed to submit form: $e');
  }
}