Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Simplify repetitive form code #2231

Open
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

lindapaiste
Copy link
Collaborator

Background:
In forms which use react-final-form we have a lot of repeated boilerplate. For example every field has the same error code:

{field.meta.touched && field.meta.error && (
  <span className="form-error">{field.meta.error}</span>
)}

Changes:

  • Create UI component FormField for an input with a label and an optional error message.
  • Create logic component FinalFormField which uses the Form component from the react-final-form package and passes the props from the generated field down to the FormField UI.
  • Use this new FinalFormField component in forms:
    • AccountForm
    • LoginForm
    • ResetPasswordForm
    • SignupForm

I have verified that this pull request:

  • has no linting errors (npm run lint)
  • has no test errors (npm run test)
  • is from a uniquely-named feature branch and is up to date with the develop branch.
  • is descriptively named and links to an issue number, i.e. Fixes #123

# Conflicts:
#	client/modules/User/components/AccountForm.jsx
#	client/modules/User/components/LoginForm.jsx
#	client/modules/User/components/NewPasswordForm.jsx
#	client/modules/User/components/SignupForm.jsx
@raclim raclim added this to the MINOR Release for 2.13.0 milestone Mar 8, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants