This ties in to my earlier question regarding converting values that are
submitted before placing them in the db.  I figured out how to go about
doing this just fine, thanks to the Clarification of add_valid and me
realizing my controller wasn't calling things in the proper order.

But now I'm trying to convert from what is in the db, to a more sane value
for humans to read.  I figured out that I need to use $field->default
instead of $form->add_valid (I think?).

Here's what I'm doing:

if ($form->submitted_and_valid) {
  #process it, stuff it in the db
} else {
  $form->model->default_values($c->model('DB::Thing'));
}

I've been looking through the code for HTML::FormFu, HTML::FormFu::Model,
HTML::FormFu::Model::DBIC, Catalyst::Controller::HTML::FormFu, etc.

After that call to $form->model->default_values, what happens?  I see that
at the end of default values, there is a return $form.  But I don't see
anywhere that is doing $c->stash->{'form'} = $whatever.  My guess is I'm
just missing where ever that gets done (or it's some automagical thing).

I ask because in trying to figure out how I should do this, I thought I'd
look and see how default_values work.  I thought that it'd be as simple as:

$form->model->default_values($c->model('DB::Thing'));
my $converted_form = do_conversion($form);
$c->stash->{'form'} = $converted_form;

Or perhaps even:
$form->model->default_values($c->model('DB::Thing'));
my $converted_form = do_conversion($c->stash->{'form'});
$c->stash->{'form'} = $converted_form;

But neither of those seems to work.  The best I've been able to get, no
matter what I try, is that the form contains what is in the db
pre-conversion, or the form contains a bunch of empty data.  What am I
missing?
_______________________________________________
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