[Catalyst] Insert Multiple rows
Johan Lindstrom
johanl at DarSerMan.com
Mon Dec 19 16:52:17 CET 2005
At 16:12 2005-12-19, Will Smith wrote:
>Hi Andy -
>Thanks for your time and instruction - But that's not what I want to do.
>Could I explain one more time:
>Normally on the template, I have 1 box - named Cdname, and this could be
>added to the table using the do_add sub created by the Scaffold
>Helper(using the From_Form/As_Form), when I hit enter, 1 new row will be
>created. Now I run into the case that I need to have on the TT 2 or more
>boxes of the same name Cdname, so that I could enter in every box the name
>of the CD and hit enter, then the do_add will insert into the table more
>than 1 row at a time. I guess this call: Insert multiple rows into the
>database.
Your description is very confusing to me, so please tell me if what I
describe now is not what you want.
Normally there is one Textfield (your "box"???) for entering "CD Name".
This would create one new entry in the "cd" table.
The goal is to be able to have many "CD Name" Textfields for creating many
CD entries at the same time.
If the name is all you want to specify when creating a CD, then you want
what Andy suggested. One form, with many Textfields with the same name.
CD Name 1: <input type="text" name="cd_name"><br>
CD Name 2: <input type="text" name="cd_name"><br>
CD Name 3: <input type="text" name="cd_name"><br>
... etc ...
As per Andy's answer, in the controller you can access the list of cd names as:
my $cd_names_array_ref = $c->req->param('cd_name');
and then you need to loop over the names and create each row the same way
you do now with the scaffolding code.
Does that sound like what you're trying to achieve?
/J
-------- ------ ---- --- -- -- -- - - - - -
Johan Lindström Sourcerer @ Boss Casinos johanl AT DarSerMan.com
Latest bookmark: "TCP Connection Passing"
http://tcpcp.sourceforge.net/
dmoz: /Computers/Programming/Languages/JavaScript/ 12
More information about the Catalyst
mailing list