Conversation
CAL-579 Highlight required inputs instead of yellow warning message
Issue SummaryWe have updated one of the Cal.Com events with text inputs, now it has radio buttons.
Actual Result: I see a yellow warning message - Expected Result: I expect them to be highlighted in red |
|
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
sean-brydon
commented
Dec 12, 2022
Comment on lines
+318
to
+332
| if (eventType.customInputs.length > 0) { | ||
| // find all required custom inputs and ensure they are filled out in the booking form | ||
| const requiredCustomInputs = eventType.customInputs.filter((input) => input.required); | ||
| const missingRequiredCustomInputs = requiredCustomInputs.filter( | ||
| (input) => !booking?.customInputs?.[input.id] | ||
| ); | ||
| if (missingRequiredCustomInputs.length > 0) { | ||
| missingRequiredCustomInputs.forEach((input) => { | ||
| bookingForm.setError(`customInputs.${input.id}`, { | ||
| type: "required", | ||
| }); | ||
| }); | ||
| return; | ||
| } | ||
| } |
Member
Author
There was a problem hiding this comment.
We have to do this cause required prop with radix doesnt seem to work with rhf
sean-brydon
commented
Dec 12, 2022
| {input.label} | ||
| className={classNames( | ||
| "mb-1 block text-sm font-medium text-gray-700 transition-colors dark:text-white", | ||
| bookingForm.formState.errors.customInputs?.[input.id] && "!text-red-700" |
Member
Author
There was a problem hiding this comment.
For now all the other errors are handled by rhf
sean-brydon
commented
Dec 12, 2022
Comment on lines
+783
to
+786
| {bookingForm.formState.errors.customInputs?.[input.id] && ( | ||
| <div className="mt-px flex items-center text-xs text-red-700 "> | ||
| <p>{t("required")}</p> | ||
| </div> |
JeroenReumkens
approved these changes
Dec 12, 2022
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
What does this PR do?
Display a nicer error message to the user when a radio option is required.
@Jaibles Do you have a design for required radio buttons? Will come back to this if one gets created