From 8f86fe335d426200584ca2bda4cc44d68baf8031 Mon Sep 17 00:00:00 2001
From: David Schmidt
Date: Mon, 29 Oct 2012 14:43:28 +0100
Subject: [PATCH] builder and default cannot coexist ...
... so you need to override '_build_unique_constraints'
instead of setting a default for the 'unique_constraints'
attribute.
---
lib/HTML/FormHandler/TraitFor/Model/DBIC.pm | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/lib/HTML/FormHandler/TraitFor/Model/DBIC.pm b/lib/HTML/FormHandler/TraitFor/Model/DBIC.pm
index 9c8e8c9..7afeb72 100644
--- a/lib/HTML/FormHandler/TraitFor/Model/DBIC.pm
+++ b/lib/HTML/FormHandler/TraitFor/Model/DBIC.pm
@@ -178,13 +178,13 @@ For fields that are marked "unique", checks the database for uniqueness.
The unique constraints registered in the DBIC result source (see
L) will also be inspected
for uniqueness unless the field's 'unique' attribute is set to false.
-Alternatively, you can use the C
-attribute to limit uniqueness checking to only a select group of unique
+Alternatively, you can override C<_build_unique_constraints>
+to limit uniqueness checking to only a select group of unique
constraints. Error messages can be specified in the C
attribute. Here's an example where you might want to specify a unique
widget name for a given department:
- has '+unique_constraints' => ( default => sub { ['department_widget_name'] } );
+ override '_build_unique_constraints' => sub { return ['department_widget_name']; };
has '+unique_messages' => (
default => sub {
{ department_widget_name => "Please choose a unique widget name for this department" };