-
Notifications
You must be signed in to change notification settings - Fork 21
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Implement custom sorting of error messages
Currently this depends on there being a #error_order method being present on the object/model associated with the builder. I went for this approach so that with objects that are represented by several forms through an app, there's no duplication in the views. It may be worth reconsidering this, but it feels broadly sensible. The way ordering works is the #error_order method should return an array of attribute names, eg: [:name, :email, :age] and when building the list of errors the error summary promotes these to the start. Any errors on attributes that aren't covered by #error_order will appear after those that are, in the order they were defined in the object or model. If there is no #error_order method on the object, don't try to re-order and just go with what Rails gives us, which is the order they were defined.
- Loading branch information
1 parent
f873492
commit 019f9eb
Showing
4 changed files
with
142 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
This file contains 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
This file contains 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