| Project: | Flag |
| Version: | 6.x-2.x-dev |
| Component: | Flag core |
| Category: | task |
| Priority: | normal |
| Assigned: | quicksketch |
| Status: | closed (fixed) |
Issue Summary
Right now our $flag->validate() function calls form_set_error() directly, and does not provide any return value (such as TRUE or FALSE) if the validation succeeds or fails. This has the problem that it's difficult to find and report errors when using non-form-based editing or creation of flags (such as doing Import/Export as described in #335453: Import/Export Support).
This patch instead makes $flag->validate() return a list of validation errors (if any). It's modeled after the same format used by Field module in Drupal 7. The list of returned field errors is keyed by the field ID, then each field has an array of errors that have been flagged on it. This particular format is a bit verbose but works beautifully with array_merge_recursive(), so multiple validation handlers can build up a list of errors per field with ease (as used in #285237: Ability to disallow a flag/unflag operation).
| Attachment | Size |
|---|---|
| flag_errors.patch | 2.63 KB |
Comments
#1
A bit of extra PHPdoc.
#2
Arg, consistency in the PHPdoc...
#3
Committed.
#4
Automatically closed -- issue fixed for 2 weeks with no activity.