[html-formfu] Question about DBIC-integration

Carl Franks fireartist at gmail.com
Tue Feb 12 15:34:39 GMT 2008


On 12/02/2008, Andreas Marienborg <omega at palle.net> wrote:
>
> On Feb 12, 2008, at 10:57 AM, Carl Franks wrote:
>
> > On 11/02/2008, Andreas Marienborg <omega at palle.net> wrote:
> >> second question:
> >>
> >> I need to constraint my options in a select based on the user that is
> >> logged in. Is that possible, or should I start tailing trunk and try
> >> to cook up a patch that lets you specify a token or somesuch replaced
> >> by $c->user->id for instance?
> >
> > I've already added support in trunk for adding a DBIC constraint based
> > on a value on the form stash.
> >
> > So, in your element config:
> >    ---
> >    type: Select
> >    model_config:
> >      DBIC:
> >        condition_from_stash:
> >          $column-name: $stash-key
> >
> > Will essentially do:
> >    $row->search({ column-name => $form->stash->{ $stash-key } });
> >
> > So if you can get the user id onto the stash easily enough, this might
> > be a solution.
> >
>
> I presume I can do this in my controllers and it will be work when I
> render the form in my controller afterwards?

Um, no.
The Select is populated during process(), which is called by
Catalyst-Controller-HTML-FormFu before it puts the form on the stash.

I implemented 'condition_from_stash' for a MultiForm I was working on,
and hadn't tried using it for anything else yet.

At the moment, if you're using the Cat Attributes, the only way I can
think of getting something onto the stash before process() is called
is to create a subclass of Select.

Maybe something more along the line of Roles would be better?
so in your config you could do something like:
    roles: ['Catalyst::StashUserID']
which would load the relevant class, and do the dirty work.

Hmm, why do I keep making more work for myself? ;)

I've also just realised, now that the options_from_model() happens
during post_process(), that means it won't work with AutoSet
constraints, which "isn't good".
I'm going to have to go back through my history and figure out exactly
why I did that, and if it'll break anything to revert it.

> I might also be wanting to start some HTML::FormFu::LDAP along the
> lines of HTML::FormFu::DBIC with constraints etc, as we might need
> that for a job project

Sounds interesting, feel free to discuss it on-list, though I haven't
had much experience with LDAP, just basic logins.

Carl



More information about the HTML-FormFu mailing list