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

Error messages should appear with form controls #7985

Open
johnriedel opened this issue Jan 15, 2025 · 2 comments · May be fixed by #7986
Open

Error messages should appear with form controls #7985

johnriedel opened this issue Jan 15, 2025 · 2 comments · May be fixed by #7986

Comments

@johnriedel
Copy link
Contributor

johnriedel commented Jan 15, 2025

Is your feature request related to a problem? Please describe.
I recommend displaying form errors in form pop-up modals (ie: Create Wizard). A good example of a problem I see is with the "Import From JSON" plugin action functionality. Here are some details.

When I click "Import From JSON" in the action menu, a pop-up modal appears with a file-input control that expects a file with JSON contents.

Image

Image

If I choose a file that fails validation, a red X appears next to the form with no information about what the error is, why validation failed, or what I need to fix.

Image

Instead, I have to close the pop-up modal and look at the top of the screen to read the notification error.

Image

Then I have to re-open the pop-up modal and try again. As you can imagine, this is not ideal especially if there are a number of form controls that need to be populated in the pop-up modal.

Describe the solution you'd like
I think it makes more sense for every form control to have an associated error message that would appear immediately under the control. That way, the validation feedback is immediate without having to close, reopen, and repopulate the pop-up modal.

Image

As far as implementation is concerned, a plugin control's validation function will have a second optional parameter, "fail", which is a function that takes one argument, an error message. So if validation fails, the validation function would simply contain one of the following code options:

fail('This file must contain JSON.'); return false;
....or....
return fail('This file must contain JSON.');

For example:

Image

Describe alternatives you've considered

Additional context

@johnriedel
Copy link
Contributor Author

Code updates complete. Opening PR soon.....

@johnriedel
Copy link
Contributor Author

Associated PR: #7986

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging a pull request may close this issue.

1 participant