[Rt-commit] rt branch, 4.4/custom-field-validate-value-callback, created. rt-4.4.4-96-g36d4912aa2
? sunnavy
sunnavy at bestpractical.com
Tue Apr 14 17:27:05 EDT 2020
The branch, 4.4/custom-field-validate-value-callback has been created
at 36d4912aa2b473ce1e908c2d5b44b9d3bf58cadc (commit)
- Log -----------------------------------------------------------------
commit 36d4912aa2b473ce1e908c2d5b44b9d3bf58cadc
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..32056cdd6c 100644
--- a/share/html/Elements/ValidateCustomFields
+++ b/share/html/Elements/ValidateCustomFields
@@ -68,8 +68,26 @@ 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 );
+ $valid = 0;
+ next;
+ }
+
my @values = _NormalizeObjectCustomFieldValue(
CustomField => $CF,
Value => ($submitted->{Values} // $submitted->{Value} // $submitted->{Upload}),
-----------------------------------------------------------------------
More information about the rt-commit
mailing list