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.<br>
<br>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?).<br><br>Here's what I'm doing:<br>
<br>if ($form->submitted_and_valid) {<br> #process it, stuff it in the db<br>} else {<br> $form->model->default_values($c->model('DB::Thing'));<br>}<br><br>I've been looking through the code for HTML::FormFu, HTML::FormFu::Model, HTML::FormFu::Model::DBIC, Catalyst::Controller::HTML::FormFu, etc.<br>
<br>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).<br>
<br>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:<br><br>$form->model->default_values($c->model('DB::Thing'));<br>
my $converted_form = do_conversion($form);<br>$c->stash->{'form'} = $converted_form;<br><br>Or perhaps even:<br>$form->model->default_values($c->model('DB::Thing'));<br>my $converted_form = do_conversion($c->stash->{'form'});<br>
$c->stash->{'form'} = $converted_form;<br><br>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?<br>