-
Notifications
You must be signed in to change notification settings - Fork 6
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
Fix required option in INJECT_* type form fields #852
Conversation
The current code will avoid saving the 'required' option as 'true', thereby avoiding the error message in the frontend saying, 'you need to fill out every required field'.
This likely the wrong solution to the problem at hand, sadly I could not come up with a better one yet, as I do not fully understand the dataflow between an Any and every suggestion or critisim is more than welcome! |
This is a fix for already existing forms, which haven't been updated yet.
When editing an already existing form, this should also fix the 'required' option, on any already existing 'INJECT_' type fields.
@@ -27,6 +27,9 @@ export const AutoFormField = ({ fieldProps, control, disabled, submittedValue }: | |||
else defaultValue = '' | |||
} | |||
|
|||
if (fieldProps.type.startsWith('INJECT_')) | |||
fieldProps.required = false |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Don't mutate prop values in rendering code, introduce a new variable instead
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Hopefully fixed the issue!
Please check and advise
Hopefully resolves the following request by @Isti01: 'Don't mutate prop values in rendering code, introduce a new variable instead'
243ea45
to
14f290b
Compare
Already part of staging |
The current code will avoid saving the 'required' option as 'true', thereby avoiding the error message in the frontend saying, 'you need to fill out every required field'.