[html-formfu] defaults_from_model doesn't call deflators

Carl Franks fireartist at gmail.com
Mon Feb 4 22:02:13 GMT 2008


On 04/02/2008, Moritz Onken <onken at houseofdesign.de> wrote:
> Hi,
>
> I created a DateTime deflator in the form config file but this
> deflator isn't called on defaults_from_model. I can't find a deflator
> call in the source of HTML::FormFu::Model::DBIC. Is supposed to be? I
> could add the deflator to the dbic table but I prefer the formfu
> deflator.
>
> I could write a patch which calls all the deflators a field has.

Just to check we're on the same page here...

Your DBIC class should be using DBIx::Class::InflateColumn::DateTime -
which turns your column value into a DateTime object.

Your corresponding FormFu field should be using
HTML::FormFu::Deflator::DateTime to ensure that the DateTime object
gets correctly stringified when it's used in your form.

If you're not already using DBIx::Class::InflateColumn::DateTime, you
shouldn't need to be using a FormFu Deflator.

The FormFu Deflator will only get called when you print (or otherwise
stringify) your form - specifically, it gets called during
$element->render_data(), which gets called during $form->render;

This an example of what defaults_from_model() essentially does - (say
the column is called 'start_time') -

     $form->get_field('start_time')->default( $row->start_time );

...so the deflators shouldn't get called during this stage.

Does that makes things clearer?

Carl



More information about the HTML-FormFu mailing list