[html-formfu] Creating options in many_to_many_select

Zbigniew Lukasiak zzbbyy at gmail.com
Sun Dec 16 12:11:47 GMT 2007


On Dec 16, 2007 10:25 AM, Carl Franks <fireartist at gmail.com> wrote:
> On 16/12/2007, Zbigniew Lukasiak <zzbbyy at gmail.com> wrote:
> > Thanks for the explanation.  Is it possible to decouple it from
> > Catalyst by putting the schema on the stash?
> > I know FormFu is mostly used with Catalyst - but you never know and
> > beside that it would simplify testing.
>
> Yes, I initially thought it not too dependant on Catalyst - you just
> need an object in $form->stash->{catalyst} that supports a model()
> method - but it makes sense to not have to bother with that.
>
> How about:
> * if db: { model: x } is set, do $db = stash->{catalyst}->model(
> args->{db}{model} )
> * else do $db = stash->{ args->{db}{stash} }
>

I would rather do it the other way around - first look for the 'db'
argument.  I would also update the catalyst controller to put the
schema on the form stash as 'db' - this is just like the advice people
give on the Catalyst mailing list about using context in the model -
don't just insert the whole context into the model - filter the things
that you'll need.

> * and if db: { schema: x } is set, do $db = $db->resultset( args->{db}{schema} )

I would not bother with that - in fact what is the Catalyst model for
DBIC is also a DBIC schema - so you should not use schema to mean the
resultset.  You can have another argument for the resultset (by
default ucfirst( form_name ) can be used as the resultset name).

By the way there is also another question - how do you plan to extend
the model stuff to include other models (like LDAP)?  I think you need
another argument that would specify the model to be used and load the
model conditionally.

Zbyszek
http://brudnopis.blogspot.com/



More information about the HTML-FormFu mailing list