Hi Carl,

In the edit action should appear the column name "fil" and not file, to match 
the column name of the file in the database and form:

if ($form->submitted_and_valid) {
  #Set a hashref for the empty file field because otherwise FileUpload inflator 
ignores it
  unless ($form->param('fil')) {
    $c->req->params->{fil} = {};
    $form->process;
  }

  $form->model->update($anunt);
  $c->flash(message => "The data was updated successfully.");
  $c->res->redirect($c->uri_for_action("/admin/anunturi/list"));
}
else {
  $form->model->default_values($anunt);

  my ($filename, $filename_label, $anunt_id);
  if ($anunt->fil) {
    $anunt_id = $anunt->id;
    $filename = $anunt->fil->{filename};
    $filename_label = encode_entities($filename);
  }

  $form->get_element({name => 'existing_file'})->content_xml(qq~<a href="~ . 
$c->uri_for($c->config->{anunturi_url}, $anunt_id, $filename)->path . 
qq~">$filename_label</a>~);

  #Close the file handle because it doesn't get out of scope here
  #And as a clarification, this is needed because otherwise the file on the 
disk can't be moved/deleted (under Windows)
  #after this code was executed and more and more files remain "opened"
  undef $anunt->fil->{handle} if ref($anunt->fil) eq 'HASH';
}

Octavian


_______________________________________________
HTML-FormFu mailing list
HTML-FormFu@lists.scsys.co.uk
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu

Reply via email to