You want to include the ID in the URL so that it persists when
bookmarked, and using a session doesn't provide that feature.
I understand what your trying to do, but the form action does not
require the ID to be included, because posted form requests first
require an HTML page to display the form.
Let me example.
1) User follows a link with the ID.
2) HTML with the form is shown in the browser, with the ID in the URL.
3) User enters form data, and submits the form.
4) A response from the server is shown to the user.
In step #2 when the form is displayed. You should take the ID from the
URL and add it as a hidden field in the form.
In step #3 the action that handles the form request does not need the
ID in the URL because it will be in the posted data.
In step #4 as part of the response you redirect the user to a URL that
contains the ID.
Also.
I would create a simple Helper object for your views. Not one that
creates an HTML link, because Cake comes with Form and Html helpers to
do that. All you need to do is modified a Router array to include the
ID
for example;
$html->link('Somewhere',$myhelper-
>id(array('controller'=>'documents','action'=>'show')));
You create a helper called Myhelper, and add a function called "id"
that injects your ID from the URL into the array. Now you can call all
various helper objects that require routed links.
I think you can inject the ID as a get request like this (I can't
remember how to handle gets with params, but I think its like this)
function id( $arr )
{
$arr['?'] = array('id'=>$this->params['id']);
}
That should provide Html that looks like this in your view
<a href="/documents/show?id=#####">Somewhere</a>
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups "CakePHP" group.
To post to this group, send email to cake-php@googlegroups.com
To unsubscribe from this group, send email to cake-php+unsubscribe@googlegroups.com
For more options, visit this group at http://groups.google.com/group/cake-php?hl=en
-~----------~----~----~----~------~----~------~--~---
No comments:
Post a Comment