Skip to content

Add defaultFormStateBehavior initialRender type "populateRequiredDefaults" #4604

Open
@jackmead515

Description

@jackmead515

Prerequisites

What theme are you using?

mui

Is your feature request related to a problem? Please describe.

Integrating with Pydantic on the backend, I have many default variables set to allow my users quick form generation and form submission. My users also don't like the fact that they cannot delete the entire input box to put in there own value (it prevents them from doing this due to the nature of how defaults are populated).

I can manipulate this behavior by setting:

experimental_defaultFormStateBehavior={{
   emptyObjectFields: 'skipEmptyDefaults'
}}

To ease this.

However, on the frontend, there is no feature to allow for "initial default generation", such that when the prop formData is past in as {}, the defaults can populated for the form initially.

Describe the solution you'd like

With a feature flag such as:

experimental_defaultFormStateBehavior={{
   initialRender: 'populateRequiredDefaults'
}}

The form would be prepopulated (even with a blank object such as {}). In combination with emptyObjectFields: 'skipEmptyDefaults', a user could have the defaults shown to them, while also being able to delete it if they want too.

Describe alternatives you've considered

No response

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions