[html-formfu] Calculating a DateTime using a custom inflator

Mike Glen mike.glen at mindsweep.net
Thu Apr 30 11:50:42 GMT 2009


I am trying to calculate an end DateTime from an entered start DateTime 
and a duration (in minutes) using an custom inflator
          - type: Hidden
            name: duration
            value: 300
          - type: DateTime
            name: start_time
            label: 'Start Date / Time'
            auto_inflate: 1
            constraints:
               - type: Required
          - type: Hidden
            name: end_time
            inflator: '+MyCustomInflator::EndDate'

package MyCustomInflator::EndDate;

use strict;
use base 'HTML::FormFu::Inflator::DateTime';

sub new {
    my $self = shift->SUPER::new( @_ );
    return $self;
}

sub inflator {
    my ( $self, $value ) = @_;
    my $d = $self->form->input->{start_time_day};
    my $m = $self->form->input->{start_time_month};
    my $y = $self->form->input->{start_time_year};  
    my $h = $self->form->input->{start_time_hour};
    my $min = $self->form->input->{start_time_minute};
    my $dur = $self->form->input->{duration};
    my $dt = $self->SUPER::inflator( "$d-$m-$y $h:$min" );
    return $dt->add( minutes => $dur );
}

When i submit the form  the validation  fails  for the  end_time element
$form->get_error( name => 'end_time' )  returns 
HTML::FormFu::Exception::Inflator

any ideas where i'm going wrong?

Thanks

-- 
MINDsweep
25 albany street
edinburgh - UK - eh1 3qn

m: 07786984428


MINDsweep www.mindsweep.net is a division of c2sky services limited
www.c2sky.net

This e-mail may contain confidential information.  It is intended solely
for the attention of the designated recipient(s).  If you are not the
intended recipient, you must not make any use of the information
contained in the e-mail or cause or allow anyone to do so.  Please
contact the sender immediately and delete the message. 





More information about the HTML-FormFu mailing list