2009/4/3 Leanan Sidhe <[email protected]>:

In response to your previous message - if you're typically needing the
processed / formatted values, you should probably be using DBIx::Class
inflators / deflators.
It's not hard to write custom inflators / deflators - just look at the
code of some on cpan.
The following comments are therefore only if you're determined not to do that ;)
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?).
default() is for use before displaying the form. It's what's used by

add_valid() is for use after a form has been submitted.
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).
Any changes you make to the form, work on that same form.
The only reason methods return the form object, is so you can chain
method calls, such as:

Because all perl objects are references, if you do:
my $form = $c->stash->{form};
then you never need to put the form back on the stash after making
changes to the form, because it's still the same object.
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:

my $converted_form = do_conversion($form);
$c->stash->{'form'} = $converted_form;

Or perhaps even:
my $converted_form = do_conversion($c->stash->{'form'});
$c->stash->{'form'} = $converted_form;
Both of these examples should work, logically, so the problem must be
inside do_conversion().

I'd suggest not returning a new form from do_conversion(), so it
really should just be:
my $form = $c->c->stash->{form};
$form->model->default_values( $row );
do_conversion( $form );

Whatever happens in do_conversion(), you should be getting the value
that model->default_values() set with
and updating it with
$field->default( $value );


Search Discussions

Discussion Posts


Related Discussions

Discussion Navigation
viewthread | post
posts ‹ prev | 2 of 2 | next ›
Discussion Overview
grouphtml-formfu @
categoriesperl, catalyst
postedApr 3, '09 at 6:19p
activeApr 4, '09 at 8:55a

2 users in discussion

Leanan Sidhe: 1 post Carl Franks: 1 post



site design / logo © 2023 Grokbase