[Jifty-commit] r1272 - in jifty/trunk: lib/Jifty/Action
jifty-commit at lists.jifty.org
jifty-commit at lists.jifty.org
Tue Jun 13 07:58:08 EDT 2006
Author: jesse
Date: Tue Jun 13 07:58:06 2006
New Revision: 1272
Modified:
jifty/trunk/ (props changed)
jifty/trunk/lib/Jifty/Action/Record.pm
Log:
r12543 at pinglin: jesse | 2006-06-13 03:37:30 +0200
* Enable validate_xxxx subs on the model to cascade to ajax.
Modified: jifty/trunk/lib/Jifty/Action/Record.pm
==============================================================================
--- jifty/trunk/lib/Jifty/Action/Record.pm (original)
+++ jifty/trunk/lib/Jifty/Action/Record.pm Tue Jun 13 07:58:06 2006
@@ -180,13 +180,23 @@
# build up a validator sub if the column implements validation
# and we're not overriding it at the action level
- if ( $column->validator and not $self->can("validate_$field")) {
+ my $validate_method = "validate_" . $field;
+
+ if ( ($column->validator || $self->record->can($validate_method)) and not $self->can($validate_method)) {
+ warn "it has a validator or a $validate_method";
$info->{ajax_validates} = 1;
$info->{validator} = sub {
my $self = shift;
my $value = shift;
- my ( $is_valid, $message )
- = &{ $column->validator }( $self->record, $value );
+ warn "Called for $value";
+ my ( $is_valid, $message );
+ if ( $self->record->can($validate_method) ) {
+ warn "pciked it up";
+
+ ($is_valid, $message) = $self->record->$validate_method($value);
+ } else {
+ ( $is_valid, $message ) = &{ $column->validator }( $self->record, $value );
+ }
if ($is_valid) {
return $self->validation_ok($field);
}
@@ -205,7 +215,6 @@
}
};
}
-
my $autocomplete_method = "autocomplete_" . $field;
if ( $self->record->can($autocomplete_method) ) {
$info->{'autocompleter'} ||= sub {
More information about the Jifty-commit
mailing list