remote forms: infering field metadata
Nobody has claimed this yet.
- Dominant language
- JavaScript
- Stars
- 20.8k
- Forks
- 2.3k
- Avg merge
- 1d 16h
- Merged PRs (30d)
- 156
Description
Describe the problem
The new remote form functions allow us to beautifully centralize validation. The result is vastly simplified form components and templates.
With some information about the types of fields a form expected, we can almost programmatically generate forms based on the remote. We would need some field metadata, which at the least would include:
- Field names
- Field types (at least precise enough to guess the right
<input type={...}> - Whether the field is required or not (which is often rendered as a
*)
However the current API doesn't provide us with any information on the form's validation schema in the remote.
Describe the proposed solution
The simplest solution is to provide access to the raw schema in RemoteForm. However, from what I can tell, the standard schema is pretty low-level and isn't designed to be consumed directly by developers.
A cleaner solution would be something like a remoteForm.fields getter which returns an array of field metadata that can be used to build a form.
Alternatives considered
- Manually building forms - already a much nicer experience than previously, but one wonders if parts of it can be automated.
- Manually importing the shared schemas to the frontend and parsing them, but this seems like a lot of work for this kind of this.
- The
remoteForm.fieldmethod - although it seems to be built for a completely different purpose
Importance
nice to have
Additional Information
No response
Contributor guide
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
No file or test is named in the issue. Start by locating the RemoteForm API and its validation schema handling, then compare the existing remoteForm.field method with the proposed fields metadata; done means an agreed API exposes field names, usable types, and required status for form generation.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- javascript
- Domain
- frontend
- Issue type
- Feature
- Difficulty
- 5/5
- Estimated time
- Over a week
- Activity status
- Stale
- Clarity
- Needs clarification
- Newbie friendliness
- 35/100