Support for Drupal 7 is ending on 5 January 2025—it’s time to migrate to Drupal 10! Learn about the many benefits of Drupal 10 and find migration tools in our resource center.
Currently a generic message is printed when a relation fails to be saved due to field validation of one or more fields throwing a FieldValidationException.
It'd be helpful if the set of errors returned from field validation were printed so the user has a better idea of why the field validation failed.
Comment | File | Size | Author |
---|---|---|---|
#3 | 2546418-3.patch | 827 bytes | mikran |
| |||
#2 | relation-improve_watchdog_message_to_include_fields_that_failed_validation-2546418-1.patch | 676 bytes | caxy4 |
Comments
Comment #2
caxy4 CreditAttribution: caxy4 at ThinkShout commentedAttaching a patch that prints all fields that failed validation as an array.
I wasn't sure whether all fields would fit the format I encountered in my test cases, which was:
...so I chose to print the entire
$e->errors
array.Although it's ugly, it gets the information in the watchdog message that'll help the user resolve their field validation error.
This patch builds on https://www.drupal.org/node/1362304 which was the initial implementation of logging a watchdog error when field validation fails.
Comment #3
mikran CreditAttribution: mikran at Mediamaisteri Oy commentedI think there is some structure to the format of errors array. I found this from relation entity collector module:
so I think we can use the same iteration structure and set multiple log messages similarly what relation entity collector here is doing.
Attached patch does just that.
Comment #4
mikran CreditAttribution: mikran at Mediamaisteri Oy commentedcommitted