aws-amplify / aws-amplify/amplify-codegen-ui
Enhance Form Generation Scalability with Seamless Input Value Overrides
- Dominant language
- TypeScript
- Stars
- 31
- Forks
- 30
- PR merge metrics
- No merged PRs in 30d
Description
### 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:
```tsx
// ParentComponent.tsx
import { v4 } from 'uuid';
import ComponentCreateForm from '...';
const uuid = v4();
...
```
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.
Contributor guide
Research direction
Start by tracing the generated form component's overrides and how its initialValues or modelFields feed validation and submission. Confirm how the existing value, display, and disabled override props flow through the form, then verify that an override value is reflected consistently in state, validation, and submitted data.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- react, typescript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 45/100