[Catalyst] Similar attribute appears twice despite a single POST
(submit) request.
kakimoto at tpg.com.au
kakimoto at tpg.com.au
Wed Apr 29 11:22:28 GMT 2009
Hi, everyone,
I have come across something interesting.
1) User opens up a page that lists all his/her subscriptions
2) Each subscription is a url and a parameter at the end (ie 'id=3325')
3) User decides to edit one of the subscriptions. He/she clicks on one
with an id of 3389 (hence the url will point to
"http://lginsurance.com.au/subscriptions/edit?id=3389")
4) My controller, sub edit gets called, it works out some hidden values
and returns a web form/
5) The web form contains the following:
a) 'name' = Text box for subscription alias
b) 'nominated_agent_code' = Text box for nominated agent code
c) 'id' = Hidden value which has the id of the current subscription
in question
5.5) The url is now "http://lginsurance.com.au/subscriptions/edit?id=3389"
6) The user makes the necessary changes to name and/or nominated agent
code on the web form and clicks 'submit'
6.5) The Catalyst debug is as follows. Observe that the 'id' appears twice!
[info] *** Request 3 (0.176/s) [24288] [Wed Apr 29 20:57:20 2009] ***
[debug] Query Parameters are:
.-------------------------------------+--------------------------------------.
| Parameter | Value
|
+-------------------------------------+--------------------------------------+
| id | 3389 |
'-------------------------------------+--------------------------------------'
[debug] Body Parameters are:
.-------------------------------------+--------------------------------------.
| Parameter | Value
|
+-------------------------------------+--------------------------------------+
| id | 3389
|
| name | fire and theft-main concourse
level |
| submit | submit
|
| nominated_agent_id | 4 |
'-------------------------------------+--------------------------------------'
[debug] "POST" request for "users/subscriptions/update" from "123.243.50.59"
[debug] Found sessionid "d11552045b04ccd6734582a4220d47398d022325" in cookie
[debug] Restored session "d11552045b04ccd6734582a4220d47398d022325"
7) my controller, sub edit gets called.
This time, I extract all the values I got from the web form using
$c->request->params->{ <attribute-name> }; where attribute-name would be
'name','nominated_agent_code' and 'id'.
When I used data dumper to print out the value I got for 'id' , I
observed that 'id' is made out of an array of two values: '3389' and
'3389' (yet again!).
Guys, if the user is clicking on the submit button in step 6, that's a
POST request. So, why is the a 'query parameters' block present? From my
understanding, a query_parameter block is for GET requests.
I know that to get the 'id' I want which is from the body parameters, I
should use $c->request->body_parameters{'id'} but in doing so, it looks
like I am avoiding the problem and its cause rather than understand what
it is about.
Help!
More information about the Catalyst
mailing list