diff options
author | groditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2008-06-14 21:21:45 +0000 |
---|---|---|
committer | groditi <groditi@03d0b0b2-0e1a-0410-a411-fdb2f4bd65d7> | 2008-06-14 21:21:45 +0000 |
commit | 577fe414348267534faf952536025a61a3c0598f (patch) | |
tree | 002dd3dc6ae6dced494e9ce266c97054e5e9cc5e | |
parent | 283e06d64e1039a4df9e29bbd7ba815a532ab1ce (diff) | |
download | reaction-577fe414348267534faf952536025a61a3c0598f.tar.gz reaction-577fe414348267534faf952536025a61a3c0598f.zip |
improvements to MatchingPassword to have a better layout, label, and error messages as well as cleanup to Mutable role
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 |