From: Matthew Wire Date: Wed, 8 Feb 2023 22:48:25 +0000 (+0000) Subject: Log server-side validation errors so it is easier to troubleshoot/debug afform issues X-Git-Url: https://vcs.fsf.org/?a=commitdiff_plain;h=e3ebffe7f6fb172415c479d48131361983761478;p=civicrm-core.git Log server-side validation errors so it is easier to troubleshoot/debug afform issues --- diff --git a/ext/afform/core/Civi/Api4/Action/Afform/Submit.php b/ext/afform/core/Civi/Api4/Action/Afform/Submit.php index 44dc9a5d9d..df072b1d7b 100644 --- a/ext/afform/core/Civi/Api4/Action/Afform/Submit.php +++ b/ext/afform/core/Civi/Api4/Action/Afform/Submit.php @@ -68,6 +68,7 @@ class Submit extends AbstractProcessor { \Civi::dispatcher()->dispatch('civi.afform.validate', $event); $errors = $event->getErrors(); if ($errors) { + \Civi::log('afform')->error('Afform Validation errors: ' . print_r($errors, TRUE)); throw new \CRM_Core_Exception(ts('Validation Error', ['plural' => '%1 Validation Errors', 'count' => count($errors)]), 0, ['validation' => $errors]); } @@ -210,7 +211,7 @@ class Submit extends AbstractProcessor { $isRequired = $attributes['defn']['required'] ?? $fullDefn['required'] ?? FALSE; if ($isRequired) { - $label = $attributes['defn']['label'] ?? $fullDefn['label']; + $label = $attributes['defn']['label'] ?? $fullDefn['label'] ?? $fieldName; return E::ts('%1 is a required field.', [1 => $label]); } return NULL;