summaryrefslogtreecommitdiff
path: root/httemplate/edit
diff options
context:
space:
mode:
authorChristopher Burger <burgerc@freeside.biz>2019-01-09 12:28:19 -0500
committerChristopher Burger <burgerc@freeside.biz>2019-01-09 12:28:19 -0500
commit057fc61586d26199005660b908ece68a7a1da681 (patch)
tree9b8e4717f0172e32c10af88a3bc37900530c94e9 /httemplate/edit
parent0edb6050aeb65200869a12d83d8de794ed384154 (diff)
RT# 81249 - added ability to validate price plan option fields
Diffstat (limited to 'httemplate/edit')
-rw-r--r--httemplate/edit/elements/edit.html12
-rwxr-xr-xhttemplate/edit/part_pkg.cgi10
2 files changed, 22 insertions, 0 deletions
diff --git a/httemplate/edit/elements/edit.html b/httemplate/edit/elements/edit.html
index feec098f3..5e7b30674 100644
--- a/httemplate/edit/elements/edit.html
+++ b/httemplate/edit/elements/edit.html
@@ -820,6 +820,18 @@ Example:
: $opt{'html_bottom'}
%>
+% ## set extra field values for validation. ie price plan fields
+% my $extra_fields_to_validate = $opt{'extra_fields_validate'};
+% my %validate_error_messages = (
+% 'digits' => 'Please only enter numbers here.',
+% 'email' => 'Please enter a valid email here.',
+% );
+% foreach my $extra_fields (keys %$extra_fields_to_validate) {
+% my $validate_type = $extra_fields_to_validate->{$extra_fields};
+% $js_form_validate->{edit_topform}->{validate_fields}{$extra_fields} = $validate_type.': true';
+% $js_form_validate->{edit_topform}->{error_message}{$extra_fields} = $validate_error_messages{$validate_type};
+% }
+
% unless ($opt{'embed'}) {
<BR>
diff --git a/httemplate/edit/part_pkg.cgi b/httemplate/edit/part_pkg.cgi
index dd8cb13a2..78e4427e0 100755
--- a/httemplate/edit/part_pkg.cgi
+++ b/httemplate/edit/part_pkg.cgi
@@ -12,6 +12,7 @@
include('/elements/init_calendar.html').
$javascript,
'html_bottom' => $html_bottom,
+ 'extra_fields_validate' => $validate_priceplan_fields,
'body_etc' =>
'onLoad="agent_changed(document.edit_topform.agentnum);
aux_planchanged(document.edit_topform.plan);
@@ -896,6 +897,15 @@ tie my %plan_labels, 'Tie::IxHash',
map { $_ => ( $plans{$_}->{'shortname'} || $plans{$_}->{'name'} ) }
keys %plans;
+my $validate_priceplan_fields = {};
+foreach my $priceplan (keys %plans) {
+ my $plan_fields = $plans{$priceplan}->{fields};
+ foreach my $price_plan_field (keys %$plan_fields) {
+ $validate_priceplan_fields->{$priceplan."__".$price_plan_field} = $plan_fields->{$price_plan_field}->{"js_validate"}
+ if exists $plan_fields->{$price_plan_field}->{"js_validate"};
+ }
+}
+
my $html_bottom = sub {
my( $object ) = @_;