[html-formfu] using new_result with form that contains File
	element
    Moritz Onken 
    onken at houseofdesign.de
       
    Mon Jan  4 11:19:56 GMT 2010
    
    
  
> 
> (...)
> if ($form->submitted_and_valid) {
>    my $cover = $c->request->upload('cover');
>    my $inhalt = $cover->slurp;
>    my $medium = $c->model('DB::Medien')->new_result({});
>    $medium->cover($inhalt);
>    $medium->mime($cover->type);
>    $form->model->update($medium);
> (...)
> 
> Any idea on how to get this right?
> Thanks
I'd try
(...)
if ($form->submitted_and_valid) {
   my $cover = $c->request->upload('cover');
   my $inhalt = $cover->slurp;
   my $medium = $c->model('DB::Medien')->new_result({});
   $form->model->update($medium);
   $medium->cover($inhalt);
   $medium->mime($cover->type);
   $medium->update;
(...)
This adds an extra update query but shouldn't be a deal breaker.
cheers,
moritz
    
    
More information about the HTML-FormFu
mailing list