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

Display validation errors under each field. #13

Merged
merged 5 commits into from
Nov 1, 2015

Conversation

aveuiller
Copy link
Contributor

I added a new way of displaying the validation error string which print the error under the field instead of displaying everything in a popup. The result look like that:

validationerror

This new method is selected by default, but the popup can still be selected from the Activity using the line:
getFormController().setValidationErrorsDisplayMethod(ValidationErrorDisplayMethod.GENERAL);

What do you thing about it?

@dkharrat
Copy link
Owner

Nice, that's a useful feature! Thanks for the pull request. I'll review the code and let you know if I have any comments.

* You MUST set the {@link ValidationErrorDisplayMethod#context} and {@link ValidationErrorDisplayMethod#controller}
* before calling showErrors.
*/
public enum ValidationErrorDisplayMethod {
Copy link
Owner

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Instead of an enum, I believe it would be better to use an interface and provide different implementations. That way, an app can easily extend NexusDialog to support other display methods. An enum is not extensible without modifying NexusDialog itself.

setError(null) on a field will now delete the error message.
ValidationErrorDisplay is no longer an enum but is now an Interface, with one method: showErrors(List<ValidationError>).
This commit gives the full command of the error display to the user.
He will have to manually call `FormController.showValidationErrors()`
and `FormController.resetValidationErrors()`
@aveuiller
Copy link
Contributor Author

I thought afterward of the extension problem for the enum, an interface would indeed be nice.
Accepting null to reset the error message is also a good idea.

About that:
Adding a display with persistent errors (instead of a popup) made the presence of a ValidationErrorDisplay.resetErrors() meaningful.
So I added this method with an associated FormController.resetValidationErrors(), and the display of the validation errors are currently the user responsibility (as shown in ComplexForm).

dkharrat added a commit that referenced this pull request Nov 1, 2015
Display validation errors under each field.
@dkharrat dkharrat merged commit 77d327a into dkharrat:master Nov 1, 2015
@aveuiller aveuiller deleted the feat-perFieldValidationDisplay branch November 3, 2015 06:47
flibbertigibbet added a commit to flibbertigibbet/NexusDialog that referenced this pull request Mar 11, 2016
…box-wrapping

Feature/fix checkbox wrapping
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.

None yet

2 participants