On Feb 12, 2008, at 4:34 PM, Carl Franks wrote:
On 12/02/2008, Andreas Marienborg <[EMAIL PROTECTED]> wrote:
On Feb 12, 2008, at 10:57 AM, Carl Franks wrote:
On 11/02/2008, Andreas Marienborg <[EMAIL PROTECTED]> 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.
Another option (and perhaps more easy) is some sort of global stash,
which all forms inherit from.
That way I could (for catalyst) set the owner in that global stash
during Root->auto, and the condition_from_stash would just work
But roles/plugins sounds alot more powerful
- andreas
_______________________________________________
HTML-FormFu mailing list
[email protected]
http://lists.scsys.co.uk/cgi-bin/mailman/listinfo/html-formfu