[html-formfu] H:F:M:DBIC condition_from_stash

Carl Franks fireartist at gmail.com
Tue Jan 11 12:27:06 GMT 2011


On 11 January 2011 11:47, Gabor HALASZ <halasz.g at freemail.hu> wrote:
> Hi Carl!
>
> Why not accepts hashes from stash in condition_from_stash? I read the
> DBIC.pm:
>
>    if ( defined( my $from_stash = $attrs->{condition_from_stash} ) ) {
>        $condition = $condition ? { %{$condition} } : {}; # avoid overwriting
> attrs->{condition}
>        for my $name ( keys %$from_stash ) {
>            my $value = $form->stash->{ $from_stash->{$name} };
>
>            croak "input value must not be a reference"
>                if ref $value;
>
>            $condition->{$name} = $value;
>        }
>    }
>
> and If I unterstod the dump of form object well, this limitation isn't
> neccessary, but makes hard to create a flexibile conditions. I created
> various configs like this:
>
> <condition>
>  <id>
>    > 1
>  </id>
> </condition>
> <condition_from_stash>
>  name user
> </condition_from_stash>
>
> placed the condition to the form's stash (tried in Catalyst environment):
>
> $form->stash->{user} = { '!=' => $c->stash->{userRS}->name };
>
> commented out the croak line above, and I got the correct query:
>
> WHERE ( ( id > ? AND name != ? ) ): '1', 'Administrator'
>
> What's your opinion?

This looks like the same issue Yuval raised in October.
I don't think the restriction was originally intended, so I'd accept
any patch that includes tests that resolves this.

btw, it's now on github, so please branch it and send a pull request when ready.
https://github.com/fireartist/HTML-FormFu-Model-DBIC

Cheers,
Carl



More information about the HTML-FormFu mailing list