[html-formfu] How to inflate File Upload?

Carl Franks fireartist at gmail.com
Wed Mar 11 15:27:13 GMT 2009


2009/3/11 Kaare Rasmussen <kaare at jasonic.dk>:
> I wonder how to inflate a File Upload as easy as possible with
> Catalyst::Controller::HTML::FormFu.
>
> I have this construct, where images is a has_many relation from the main row,
>
>  - type: Repeatable
>    nested_name: images
>    counter_name: count
>    model_config:
>      new_empty_row_multi: image
>    elements:
>      - type: Hidden
>        name: id
>      - type: File
>        name: image
>
> The image column ends of course up with something like this as there is
> nothing telling how to inflate/deflate it.
> HTML::FormFu::QueryType::Catalyst=HASH(0xb0a6ccc)
>
> Is there an easy inflator method hiding somewhere?
> The images class has in fact also a 'name' column, where it would be nice to
> store the original filename.

I use the Inflator from HTML-FormFu-Imager
to turn picture uploads into Imager objects.

This won't fix your problem of storing the file with DBIC.
Rather than having the form field correspond to a DBIC row, I
typically name my field after a method on the source class that
accepts an Imager object, and saves it to disk.

Take note: I think the Imager inflator completely overwrites the
FormFu upload object, so you'll lose the uploaded filename.
If you're wanting to keep that, I think you'd need to forget about the
inflator, and just write a method in your source class that knows what
to do with the uploaded file.

Carl



More information about the HTML-FormFu mailing list