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?
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 ...
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->(@_)) };
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;
=for layout widget
-[% call_next %]
-[% check_value %]
+[% label_fragment %]
+[% field %]
+[% check_label %]
+[% check_field %]
+[% message_fragment %]
=cut