[Html-widget] formfu - deflators

Carl Franks fireartist at gmail.com
Mon Apr 9 16:51:35 GMT 2007

On 09/04/07, Daisuke Maki <daisuke at endeworks.jp> wrote:
> Can you clarify for me how deflators are supposed to work?
> My impression was that deflators are always run against a field during
> render() time, if one is specified in the spec. For example,
>  elements:
>     -
>        type: text
>        name: foo
>        inflator:
>           - type: +MyCustom::Inflator
>        defaltor:
>           - type: +MyCustom::Deflator
> So I want to receive some stuff in "foo" as text, but turn them into a
> Perl object while I'm working with it -- then I want to call the
> object's stringification method to turn it into a string again.
> Looking at the code in HTML::FormFu::Element::input::_render_value, I see:
>    if ( !$self->form->submitted ) {
>        for my $deflator ( @{ $self->_deflators } ) {
>            $value = $deflator->process($value);
>        }
>    }
> which threw me off. So deflators aren't run if the form has been
> submitted? Is this right?

The way they work at the moment, they´re intended to be run on values
you set yourself: $field->default($obj)
such as when you recieve a DateTime object from DBIx::Class.
When you redisplay a form, the original submitted value is used.
Filtered / inflated values aren´t used, so it shouldn´t prove a
problem that the deflators are only used when it´s not been submitted.
Of course, this is only how I think it should work - the code might
differ from my memory! I´m also open to suggestions on how it might
work better, as well.


More information about the Html-widget mailing list