Skip to content

initialValues not working for dynamic data #1487

Description

@ag13

Scope: FormRenderer

Description: When initialValues is set to a static object like initialValues={{type: {label: "test", value: "1"}}}, it correctly initialises the value but when the same data comes in from an API call and is passed to initialValues prop it fails to initialise it correctly. The useFormApi is correctly getting the initialValues but it does not pass through to the fields.

Schema: fields: [ { component: 'radio', name: 'type', label: 'Type', actions: { options: ['getTypes'], }, }]

Renderer code

<FormRenderer componentMapper={componentMapper} FormTemplate={FormTemplate} actionMapper={actionMapper} schema={schema} onSubmit={asyncSubmit} onCancel={() => console.log('Cancelling')} onReset={() => console.log('Resetting')} initialValues={dataFromApi} //{type: {label: "test", value: "1"}} subscription={{ values: true, initialValues: true }} />

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

      Milestone

      No milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions