Function useFkFieldOptions

  • Loads select options for foreign-key (x-fk) fields in a field set.

    Option values bind to the target's x-fk.value property when set (e.g. account names), otherwise to the target resource's primary key. Fields with fk.prefetch === true load immediately; others load on demand through the returned loadFkOnOpen. Options are cached per field name.

    Notes:

    • For a paginated target it requests ?limit=0 and expects { items }; for a non-paginated target it expects a bare array.
    • Invalid responses and request errors are swallowed, leaving the field without suggestions.

    Parameters

    • fields: FieldConfig[]

      The field set to scan for x-fk relationships.

    Returns {
        fkLoading: Record<string, boolean>;
        fkOptions: Record<string, FkOption[]>;
        loadFkOnOpen: (fieldName: string) => void;
    }

    fkOptions (per field name), fkLoading (per field name) and loadFkOnOpen(fieldName).

    const { fkOptions, fkLoading, loadFkOnOpen } = useFkFieldOptions(resource.fields);