Skip to content

[BUG] useForm Hook Allows external enabled to override Internal ID Check, Causing API calls with undefined ID #6867

@devarsh-mavani-19

Description

@devarsh-mavani-19

Describe the bug

The useForm hook passes queryOptions to useOne like this:

enabled: !isCreate && id !== undefined,
...props.queryOptions,

This results in the internal enabled condition (!isCreate && id !== undefined) being overridden if the user passes a custom enabled flag through queryOptions.

As a result, if the custom enabled is set to true but id is still undefined, the hook proceeds to make an API call with an invalid or missing ID — leading to unintended behavior, Or atleast doesnt look obvious behaviour.

Steps To Reproduce

pass enabled to useForm like this

useForm({
    queryOptions: {
        enabled: <my condition>
    }
})

Expected behavior

I would expect that it performs ANDing of my condition and the existing condition, since no one would never expect it to take id as undefined.

Packages

  • @refinedev/core

Additional Context

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    bugSomething isn't working

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions