On 09/04/07, Daisuke Maki <[EMAIL PROTECTED]> 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.

Carl

_______________________________________________
Html-widget mailing list
Html-widget@lists.rawmode.org
http://lists.rawmode.org/cgi-bin/mailman/listinfo/html-widget

Reply via email to