[Rt-commit] rt branch, 4.4/custom-field-validate-value-callback, created. rt-4.4.4-448-g135410c8e5

? sunnavy sunnavy at bestpractical.com
Mon May 17 13:17:02 EDT 2021


The branch, 4.4/custom-field-validate-value-callback has been created
        at  135410c8e5ecb5fe2eb00d5c60da8d5aa44c4710 (commit)

- Log -----------------------------------------------------------------
commit 135410c8e5ecb5fe2eb00d5c60da8d5aa44c4710
Author: sunnavy <sunnavy at bestpractical.com>
Date:   Wed Apr 15 05:04:52 2020 +0800

    Add ValidateValue callback in ValidateCustomFields
    
    This gives custom code a straightforward entry to validate cf values

diff --git a/share/html/Elements/ValidateCustomFields b/share/html/Elements/ValidateCustomFields
index be91199446..c8cea0e33e 100644
--- a/share/html/Elements/ValidateCustomFields
+++ b/share/html/Elements/ValidateCustomFields
@@ -68,8 +68,27 @@ while ( my $CF = $CustomFields->Next ) {
     next if $submitted->{"Values-Magic"} and exists $submitted->{"Values"}
         and ref $submitted->{"Values"};
 
+    my ( $invalid, $invalid_message );
+    $m->callback(
+        CallbackName    => 'ValidateValue',
+        Object          => $Object,
+        CustomField     => $CF,
+        Value           => \( $submitted->{Values} // $submitted->{Value} // $submitted->{Upload} ),
+        ARGSRef         => $ARGSRef,
+        CustomFieldArgs => $CFArgs,
+        Invalid         => \$invalid,
+        InvalidMessage  => \$invalid_message,
+    );
+
     $m->notes(('Field-' . $CF->Id) => $submitted->{Values} // $submitted->{Value});
 
+    if ( $invalid ) {
+        $m->notes( 'InvalidField-' . $CF->Id => $invalid_message );
+        push @res, $CF->Name . ': ' . $invalid_message;
+        $valid = 0;
+        next;
+    }
+
     my @values = _NormalizeObjectCustomFieldValue(
         CustomField => $CF,
         Value       => ($submitted->{Values} // $submitted->{Value} // $submitted->{Upload}),

-----------------------------------------------------------------------


More information about the rt-commit mailing list