[html-formfu] defaults_from_model doesn't call deflators

Carl Franks fireartist at gmail.com
Tue Feb 5 13:27:22 GMT 2008


On 05/02/2008, Moritz Onken <onken at houseofdesign.de> wrote:
> I create JSON with:
>
>
>         my $form = HTML::FormFu::ExtJS->new; #HTML::FormFu::ExtJS adds some
> functionality but inherits from FormFu
>         $form->load_config_file('someconfig.yml');
>         my $rs = $c->user->some_relationship->find($id);
>         $form->defaults_from_model($rs);
>         my $base = $form->get_all_elements;
>         $c->stash({success => 1});
>         $c->stash->{data}->{$_->name} = $_->default for(@{$base});
>         $c->forward($c->view(""JSON"));

for my $field (@{ $form->get_fields }) {
    my $data = $field->render_data;

    $c->stash->{data}->{ $data->{nested_name} }
        = $data->{value};
}

Up until a couple months ago, before the removal of the Render object
- the only supported way to *output* anything, or use any part of the
form for output was with the Render object returned by
$form->render();

Now, it's a little less clear, because render() returns a string - but
if you're not using one of the current output methods - render(),
string() or tt() - you should use render_data() - these are the only
supported ways of using the form for output.

Carl



More information about the HTML-FormFu mailing list