[Catalyst] Re: retrieving multiple values from forms

jagdish eashwar jagdish.eashwar at gmail.com
Tue Dec 18 14:26:50 GMT 2007


On Dec 18, 2007 6:56 AM, Andrew Rodland <arodland at comcast.net> wrote:

> On Monday 17 December 2007 05:27:46 pm A. Pagaltzis wrote:
> > The *sane* thing is neither.
> >
> > The sane thing is to have *TWO* methods, one that *always*
> > returns a scalar, and one that *always* returns a list. (Or
> > rather, an arrayref, because if it's just a list, it is easy to
> > improperly treat it like a scalar, whereas if it's an arrayref
> > it's impossible to forget to unpack the array when you meant to
> > do that.)
> >
> > Then you can say what you mean, you can say it *easily* either
> > way, and the result is always completely determined by what the
> > code says and not at all by what the data looks like. Sanity.
>
> Yeah, I can agree with this. I realized the same thing myself... after
> posting
> my original message of course. Teach me to wait a bit longer before
> hitting
> send in the future. Anyway yeah, what I really want is "param_list"
> or "param_aref", without any of the actual "CGI compat" of param -- param
> just comes closer to my goal than params. Not sure what the ideal behavior
> for the "only one" version would be, but params is at least practical. If
> you
> see ARRAY(0xbadfad) where you expected useful data it's not that hard to
> trace back and see what you did wrong.
>
> Andrew
> Hi,
>
> I am unable to keep up with the discussion.
>
> When I use "@role_id =3D $c->req->param(role_id)" as Andrew suggested, I =
am
> getting an error in Catalyst  saying "Can't use string ("4") as a HASH ref
> while "strict refs" in use". "4" is one of the values that the code is
> fetching.
>
> So I changed the code to read "@role_id =3D $c->req->params(role_id)" as
> Kevin suggested and put \@role_id in the stash. Now there was no error, b=
ut
> I got "ARRAY(0x987e5e0)" in the template instead of the role_id values.
>
> So I further changed the code to "$role_id =3D $c->req->params(role_id)" =
and
> put $values in the stash. Now I could access in the template the multiple
> role_ids that the code was picking up. I realised then that I pick up sin=
gle
> values also in the same way.
>
> So is the way for picking up multiple values the same as for picking up
> single values?
>
> Moving on from here, I want to pick up the corresponding role descriptions
> for each role_id from a database table and show role descriptions rather
> than the role_id's in the template.
>
> When I am picking up only a single role_id, I am able to achieve this by
> using
> "my @role_desc =3D $c->model('myleavedb::role_types')->find($role_id)"
> and putting \@role_desc in the stash.
>
> I am unable to figure out how the coding is to be done when I retrieve
> multiple role_id's.
> I tried looping over the multiple role_ids in the arrayref ($role_id), but
> couldn't get the code right.
>

    Jagdish Eashwar
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://lists.scsys.co.uk/pipermail/catalyst/attachments/20071218/435c3=
002/attachment.htm


More information about the Catalyst mailing list