24
HTTP API

Resources, Models, and Controller Overrides

Serialization customization and extension points.

Resource customization

Config keys:

  • formforge.http.resources.form_definition
  • formforge.http.resources.submission
  • formforge.http.resources.submitter
  • formforge.http.resources.file_urls.*

File URL options:

  • enabled
  • temporary
  • ttl_seconds
  • key

Form resources expose public_url when a public-link resolver is configured.

Config keys:

  • formforge.http.public_link.resolver
  • formforge.http.public_link.base_url

The resolver receives the form context and the current request. The context can include keys such as key, owner_type, owner_id, schema, meta, and version, which lets you build tenant-aware links, subdomain-specific URLs, or owner-derived public domains.

<?php

declare(strict_types=1);

namespace App\FormForge;

use EvanSchleret\FormForge\Support\FormPublicLinkResolver;
use Illuminate\Http\Request;

final class TenantAwareFormPublicLinkResolver implements FormPublicLinkResolver
{
    public function resolve(array $context, Request $request): ?string
    {
        $key = trim((string) ($context['key'] ?? ''));

        if ($key === '') {
            return null;
        }

        $ownerDomain = $request->route('owner')?->domain ?? $request->getSchemeAndHttpHost();
        $prefix = trim(config('formforge.http.prefix', 'api/formforge/v1'), '/');

        return rtrim($ownerDomain, '/') . '/' . trim($prefix . '/forms/' . $key, '/');
    }
}
public_url is resolved dynamically from the current request. If you need a fixed base URL, set formforge.http.public_link.base_url instead of deriving it from the request host.

Model overrides

Overridable keys under formforge.models.*:

  • form_definition
  • form_category
  • form_submission
  • submission_file
  • staged_upload
  • idempotency_key
  • form_draft
  • submission_automation_run
  • submission_privacy_policy
  • submission_privacy_override

Each custom model must extend the corresponding package base model.

Controller overrides

Config keys:

  • formforge.http.controllers.schema
  • formforge.http.controllers.submission
  • formforge.http.controllers.upload
  • formforge.http.controllers.resolve
  • formforge.http.controllers.draft
  • formforge.http.controllers.management

Rules:

  • extend the package controller
  • keep method signatures compatible
  • call package services instead of duplicating business logic