From cb2e8062eec418ee1cbeb00535613b9abc5c2537 Mon Sep 17 00:00:00 2001 From: Owen Leonard Date: Fri, 18 Jul 2014 14:18:12 -0400 Subject: [PATCH] Bug 7944 - attribute error could be clearer Content-Type: text/plain; charset="utf-8" If you try to create a patron and enter an extended attribute value which is required to be unique but exists in another record the error you receive is not clear. It uses the attribute code instead of the description. This patch adds description to the output. To test you must have ExtendedPatronAttributes enabled. - Edit or create an extended patron attribute and designate it a unique identifier. - Edit a patron and add a value to that attribute. - Edit another patron and try to add the same value. You should get an error which includes both the description of the attribute you tried to modify and the value you submitted. --- .../prog/en/modules/members/memberentrygen.tt | 3 +-- members/memberentry.pl | 7 ++++++- 2 files changed, 7 insertions(+), 3 deletions(-) diff --git a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt index 858f7f3..5c55e24 100644 --- a/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt +++ b/koha-tmpl/intranet-tmpl/prog/en/modules/members/memberentrygen.tt @@ -207,8 +207,7 @@
  • Passwords do not match.
  • [% END %] [% IF ( ERROR_extended_unique_id_failed ) %] -
  • The attribute value - [% ERROR_extended_unique_id_failed_value %] is already in use by another patron record.
  • +
  • [% ERROR_extended_unique_id_failed_description %] attribute value [% ERROR_extended_unique_id_failed_value %] is already in use by another patron record.
  • [% END %] diff --git a/members/memberentry.pl b/members/memberentry.pl index 959a795..11de592 100755 --- a/members/memberentry.pl +++ b/members/memberentry.pl @@ -338,8 +338,13 @@ if ($op eq 'save' || $op eq 'insert'){ $extended_patron_attributes = parse_extended_patron_attributes($input); foreach my $attr (@$extended_patron_attributes) { unless (C4::Members::Attributes::CheckUniqueness($attr->{code}, $attr->{value}, $borrowernumber)) { + my $attr_info = C4::Members::AttributeTypes->fetch($attr->{code}); push @errors, "ERROR_extended_unique_id_failed"; - $template->param(ERROR_extended_unique_id_failed_value => "$attr->{code}/$attr->{value}"); + $template->param( + ERROR_extended_unique_id_failed_code => $attr->{code}, + ERROR_extended_unique_id_failed_value => $attr->{value}, + ERROR_extended_unique_id_failed_description => $attr_info->description() + ); } } } -- 1.7.9.5