aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm7
-rw-r--r--lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm6
-rw-r--r--lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm11
-rw-r--r--share/skin/default/layout/field/mutable/matching_passwords.tt7
4 files changed, 27 insertions, 4 deletions
diff --git a/lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm b/lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm
index bbe992f..6d9d8aa 100644
--- a/lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Mutable/MatchingPasswords.pm
@@ -6,6 +6,12 @@ use aliased 'Reaction::UI::ViewPort::Field::Mutable::Password';
class MatchingPasswords is Password, which {
has check_value => (is => 'rw', isa => 'Str', );
+ has check_label => (is => 'rw', isa => 'Str', lazy_build => 1);
+
+ implements _build_check_label => as {
+ my $orig_label = shift->label;
+ return "Confirm ${orig_label}";
+ };
#maybe both check_value and value_string should have triggers ?
#that way if one even happens before the other it would still work?
@@ -14,6 +20,7 @@ class MatchingPasswords is Password, which {
my ($self) = @_;
return $orig->(@_) if $self->check_value eq $self->value_string;
$self->message("Passwords do not match");
+ return;
};
#order is important check_value should happen before value here ...
diff --git a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
index 010ea07..e2304ef 100644
--- a/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
+++ b/lib/Reaction/UI/ViewPort/Field/Role/Mutable.pm
@@ -81,7 +81,11 @@ role Mutable, which {
implements sync_from_action => as {
my ($self) = @_;
return unless !$self->needs_sync; # && $self->has_attribute;
- $self->message($self->model->error_for($self->attribute) || '');
+ if( !$self->has_message ){
+ if(my $error = $self->model->error_for($self->attribute) ){
+ $self->message( $error );
+ }
+ }
};
around accept_events => sub { ('value', shift->(@_)) };
diff --git a/lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm b/lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm
index 44c7103..02ec220 100644
--- a/lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm
+++ b/lib/Reaction/UI/Widget/Field/Mutable/MatchingPasswords.pm
@@ -5,12 +5,21 @@ use aliased 'Reaction::UI::Widget::Field::Mutable::Password';
class MatchingPasswords is Password, which {
- implements fragment check_value {
+ implements fragment check_field {
arg 'field_id' => event_id 'check_value';
arg 'field_name' => event_id 'check_value';
+ arg 'label' => 'Confirm:';
render 'field'; #piggyback!
};
+ implements fragment check_label {
+ if (my $label = $_{viewport}->check_label) {
+ arg label => $label;
+ render 'label';
+ }
+ };
+
+
};
1;
diff --git a/share/skin/default/layout/field/mutable/matching_passwords.tt b/share/skin/default/layout/field/mutable/matching_passwords.tt
index d07b784..450e5b4 100644
--- a/share/skin/default/layout/field/mutable/matching_passwords.tt
+++ b/share/skin/default/layout/field/mutable/matching_passwords.tt
@@ -2,7 +2,10 @@
=for layout widget
-[% call_next %]
-[% check_value %]
+[% label_fragment %]
+[% field %]
+[% check_label %]
+[% check_field %]
+[% message_fragment %]
=cut