Skip to content

Enhance Form Generation Scalability with Seamless Input Value Overrides #1165

Open
@roryscot

Description

@roryscot

Description

Form generation in the project is powerful but lacks scalability when it comes to overriding input values through props passed from a parent component. Currently, overrides can be specified as props, but they are not seamlessly integrated into the form's state management, validation, or submission processes. This limitation necessitates manual adjustments to the generated form components, which introduces redundancy and risks overwriting logic across different iterations of form generation.

Current Behavior

The current implementation allows for overriding input values via props in the following manner:

// ParentComponent.tsx

import { v4 } from 'uuid';
import ComponentCreateForm from '...';

const uuid = v4();
...
<ComponentCreateForm
  overrides={{
    uuid: {
      value: uuid,
      display: "none",
      disabled: true,
    },
  }}
/>

However, the overrides specified here are not seamlessly integrated into the form's state (initialValues) that drives validation and submission.

Expected Behavior

To enhance scalability and maintainability, the form generation process should allow overriding of default input values through props that seamlessly integrate into the form's state management, validation, and submission processes. This would eliminate the need for manual editing of the generated form components and ensure that custom logic can be managed outside of the form generation process.

Proposed Solution

Introduce a mechanism to pass override props that serve as default values for the form's modelFields or initialValues. This approach would enable most of the custom logic to be handled outside of the form component, allowing generated forms to be more versatile and out-of-the-box usable.

Additional Context

This improvement would significantly enhance the flexibility and scalability of form generation within the project, aligning it with best practices for component reusability and customization. It would also reduce the risk of inadvertently overwriting form logic during subsequent iterations of form generation.

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