Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fieldSchema is undefined for all fields retrieved via hooks #5819

Open
vibhor-web-headout opened this issue Apr 12, 2024 · 0 comments
Open
Labels
[missing-reproduction] If an issue does not include a reproduction [possible-bug] Possible bug which hasn't been reproduced yet

Comments

@vibhor-web-headout
Copy link

vibhor-web-headout commented Apr 12, 2024

Link to reproduction

No response

Describe the Bug

I am trying to figure out the type of field for a list of field-paths.
I saw there's a key called fieldSchema returned from useFormFields hook which a few levels in returns the fieldSchema for that specific field.

export type FormField = {
    condition?: Condition;
    disableFormData?: boolean;
    errorMessage?: string;
    fieldSchema?: FieldConfig;
    initialValue: unknown;
    passesCondition?: boolean;
    rows?: Row[];
    valid: boolean;
    validate?: Validate;
    value: unknown;
};

I am using the following code to get the fieldSchema, but it's undefined for each field

const [pageSubType, fieldConditionAndValueList] = useFormFields<
        [
            TPageSubType,
            Array<{
                value: string | number | boolean;
                passesCondition?: boolean;
                path: string;
                fieldSchema?: FieldConfig;
            }>
        ]
    >(([fields]) => [
        fields['categorisation.pageSubType']?.value as TPageSubType,
        MY_FIELD_PATH_LIST.map(path => ({
            value: fields[path]?.value as string | number,
            passesCondition: fields[path]?.passesCondition,
            path: path,
            fieldSchema: fields[path]?.fieldSchema
        }))
    ]);

To Reproduce

Use useFormFields or useAllFormFields hook to verify fieldSchema.

Payload Version

2.11.2

Adapters and Plugins

No response

@vibhor-web-headout vibhor-web-headout added the [possible-bug] Possible bug which hasn't been reproduced yet label Apr 12, 2024
@JessChowdhury JessChowdhury added the [missing-reproduction] If an issue does not include a reproduction label Apr 18, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
[missing-reproduction] If an issue does not include a reproduction [possible-bug] Possible bug which hasn't been reproduced yet
Projects
None yet
Development

No branches or pull requests

2 participants