in reply to HTML forms and variable line items
What is the best way to pass all these variables to a mason component that does all the SQL work? How do I declair the variables qty1, qty2...etc in an <%args> if the number if them is always different?
my reply:
The simple answer is, you don't. From the mason documentation:
2. %ARGS hash: This variable, always available, contains all of the parameters passed to the component (whether or not they were declared). It is especially handy for dealing with large numbers of parameters, dynamically named parameters, or parameters with non-valid variable names. %ARGS can be used with or without an <%args> section, and its contents are unrelated to what you have declared in <%args>.
Which means, that in your example you can acess qty2 with
$ARGS{'qty2'}
and you can find all your id's with
my @ids = map { /^podid(\d+)/ ; $1 } grep { /^podid\d+/ } keys %ARGS;
You might also look at making a request object and store a cgi instance on it, created with new CGI(%ARGS)
|
|---|