Bei der Gruppe, für die Sie eine Mitteilung verfassen, handelt es sich um eine Usenet-Gruppe. Wenn Sie in dieser Gruppe Nachrichten posten, ist Ihre E-Mail-Adresse für jeden im Internet sichtbar
I am not happy with the javascript delete confirm method, as it
doesn't appear if javascript is disabled and the delete happens with
no checking. I want to ask the user to confirm that he wants to delete
a record, and would like to do something like this:
1. User clicks a delete link, which points at the delete action.
2. The delete action redirects the user to the view screen for the
record with a flash message asking him to confirm the delete, and
links to confirm or reject the deletion.
3. If the user clicks the confirm link they are redirected back to the
delete action but this time with a parameter that shows the action has
been confirmed, and the deletion takes place.
4. The parameter identified in (3) is not present in stage (2), which
is how (2) knows to direct to the view screen and ask for
confirmation, rather than just processing the delete.
5. I am reusing the view screen and action in (2) so that I don't have
to build new confirm_delete screens and actions (I would need to build
about 60 of them).
I have looked for help on adding a parameter to the redirect action,
but can't find an answer. I'd be grateful for some advice and
recommendations, please.
> I am not happy with the javascript delete confirm method, as it
> doesn't appear if javascript is disabled and the delete happens with
> no checking. I want to ask the user to confirm that he wants to delete
> a record, and would like to do something like this:
> 1. User clicks a delete link, which points at the delete action.
> 2. The delete action redirects the user to the view screen for the
> record with a flash message asking him to confirm the delete, and
> links to confirm or reject the deletion.
> 3. If the user clicks the confirm link they are redirected back to the
> delete action but this time with a parameter that shows the action has
> been confirmed, and the deletion takes place.
> 4. The parameter identified in (3) is not present in stage (2), which
> is how (2) knows to direct to the view screen and ask for
> confirmation, rather than just processing the delete.
> 5. I am reusing the view screen and action in (2) so that I don't have
> to build new confirm_delete screens and actions (I would need to build
> about 60 of them).
> I have looked for help on adding a parameter to the redirect action,
> but can't find an answer. I'd be grateful for some advice and
> recommendations, please.
function delete($id) {
if (!$this->data) {
$this->set('referer', $this->referer()); // pick this up in the
view, and add it to the form
return $this->render('/elements/confirm_delete');
}
... actually delete ..
$this->redirect($this->data[$this->modelAlias]['referer']); // where
they came from
On Fri, Nov 13, 2009 at 4:14 AM, jburns <jeremybu...@me.com> wrote:
> I am not happy with the javascript delete confirm method, as it
> doesn't appear if javascript is disabled and the delete happens with
> no checking. I want to ask the user to confirm that he wants to delete
> a record, and would like to do something like this:
> 1. User clicks a delete link, which points at the delete action.
> 2. The delete action redirects the user to the view screen for the
> record with a flash message asking him to confirm the delete, and
> links to confirm or reject the deletion.
> 3. If the user clicks the confirm link they are redirected back to the
> delete action but this time with a parameter that shows the action has
> been confirmed, and the deletion takes place.
> 4. The parameter identified in (3) is not present in stage (2), which
> is how (2) knows to direct to the view screen and ask for
> confirmation, rather than just processing the delete.
> 5. I am reusing the view screen and action in (2) so that I don't have
> to build new confirm_delete screens and actions (I would need to build
> about 60 of them).
It's not so hard to do it with ordinary $html->link.
Point the delete link to a question action that do what
you want (a link to the real delete action and another
to go back).
If you can realize how to do it this way, so you could
encapsulate the all stuff creating your own helper,
overriding the $html->link method.
Best regards.
--
MARCELO DE F. ANDRADE
Belem, PA, Amazonia, Brazil
Linux User #221105
> function delete($id) {
> if (!$this->data) {
> $this->set('referer', $this->referer()); // pick this up in the
> view, and add it to the form
> return $this->render('/elements/confirm_delete');
> }
> ... actually delete ..
> $this->redirect($this->data[$this->modelAlias]['referer']); // where
> they came from
> }
> hth,
> AD
> --
> 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=.
> On Fri, Nov 13, 2009 at 4:14 AM, jburns <jeremybu...@me.com> wrote:
>> I am not happy with the javascript delete confirm method, as it
>> doesn't appear if javascript is disabled and the delete happens with
>> no checking. I want to ask the user to confirm that he wants to delete
>> a record, and would like to do something like this:
>> 1. User clicks a delete link, which points at the delete action.
>> 2. The delete action redirects the user to the view screen for the
>> record with a flash message asking him to confirm the delete, and
>> links to confirm or reject the deletion.
>> 3. If the user clicks the confirm link they are redirected back to the
>> delete action but this time with a parameter that shows the action has
>> been confirmed, and the deletion takes place.
>> 4. The parameter identified in (3) is not present in stage (2), which
>> is how (2) knows to direct to the view screen and ask for
>> confirmation, rather than just processing the delete.
>> 5. I am reusing the view screen and action in (2) so that I don't have
>> to build new confirm_delete screens and actions (I would need to build
>> about 60 of them).
> It's not so hard to do it with ordinary $html->link.
> Point the delete link to a question action that do what
> you want (a link to the real delete action and another
> to go back).
> If you can realize how to do it this way, so you could
> encapsulate the all stuff creating your own helper,
> overriding the $html->link method.
> Best regards.
> --
> MARCELO DE F. ANDRADE
> Belem, PA, Amazonia, Brazil
> Linux User #221105
> --
> 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=.
Another possibility is adding delete links within a <form> that has
method = post,
check the request method (if its POST) on the action as well.
in addition: give that form a class and css stylize it down to a link
(though why not keep it a button, buttons = post, links = get paradigm
works well too)
On Nov 13, 4:55 pm, Jeremy Burns <jeremybu...@me.com> wrote:
> On 13 Nov 2009, at 15:44, Marcelo Andrade wrote:
> > On Fri, Nov 13, 2009 at 4:14 AM, jburns <jeremybu...@me.com> wrote:
> >> I am not happy with the javascript delete confirm method, as it
> >> doesn't appear if javascript is disabled and the delete happens with
> >> no checking. I want to ask the user to confirm that he wants to delete
> >> a record, and would like to do something like this:
> >> 1. User clicks a delete link, which points at the delete action.
> >> 2. The delete action redirects the user to the view screen for the
> >> record with a flash message asking him to confirm the delete, and
> >> links to confirm or reject the deletion.
> >> 3. If the user clicks the confirm link they are redirected back to the
> >> delete action but this time with a parameter that shows the action has
> >> been confirmed, and the deletion takes place.
> >> 4. The parameter identified in (3) is not present in stage (2), which
> >> is how (2) knows to direct to the view screen and ask for
> >> confirmation, rather than just processing the delete.
> >> 5. I am reusing the view screen and action in (2) so that I don't have
> >> to build new confirm_delete screens and actions (I would need to build
> >> about 60 of them).
> > It's not so hard to do it with ordinary $html->link.
> > Point the delete link to a question action that do what
> > you want (a link to the real delete action and another
> > to go back).
> > If you can realize how to do it this way, so you could
> > encapsulate the all stuff creating your own helper,
> > overriding the $html->link method.
> > Best regards.
> > --
> > MARCELO DE F. ANDRADE
> > Belem, PA, Amazonia, Brazil
> > Linux User #221105
> > --
> > 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 athttp://groups.google.com/group/cake-php?hl=.
<j0n4s.h4rtm...@googlemail.com> wrote:
> Another possibility is adding delete links within a <form> that has
> method = post,
> check the request method (if its POST) on the action as well.
> in addition: give that form a class and css stylize it down to a link
> (though why not keep it a button, buttons = post, links = get paradigm
> works well too)
> On Nov 13, 4:55 pm, Jeremy Burns <jeremybu...@me.com> wrote:
> > On 13 Nov 2009, at 15:44, Marcelo Andrade wrote:
> > > On Fri, Nov 13, 2009 at 4:14 AM, jburns <jeremybu...@me.com> wrote:
> > >> I am not happy with the javascript delete confirm method, as it
> > >> doesn't appear if javascript is disabled and the delete happens with
> > >> no checking. I want to ask the user to confirm that he wants to delete
> > >> a record, and would like to do something like this:
> > >> 1. User clicks a delete link, which points at the delete action.
> > >> 2. The delete action redirects the user to the view screen for the
> > >> record with a flash message asking him to confirm the delete, and
> > >> links to confirm or reject the deletion.
> > >> 3. If the user clicks the confirm link they are redirected back to the
> > >> delete action but this time with a parameter that shows the action has
> > >> been confirmed, and the deletion takes place.
> > >> 4. The parameter identified in (3) is not present in stage (2), which
> > >> is how (2) knows to direct to the view screen and ask for
> > >> confirmation, rather than just processing the delete.
> > >> 5. I am reusing the view screen and action in (2) so that I don't have
> > >> to build new confirm_delete screens and actions (I would need to build
> > >> about 60 of them).
> > > It's not so hard to do it with ordinary $html->link.
> > > Point the delete link to a question action that do what
> > > you want (a link to the real delete action and another
> > > to go back).
> > > If you can realize how to do it this way, so you could
> > > encapsulate the all stuff creating your own helper,
> > > overriding the $html->link method.
> > > Best regards.
> > > --
> > > MARCELO DE F. ANDRADE
> > > Belem, PA, Amazonia, Brazil
> > > Linux User #221105
> > > --
> > > 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 athttp://groups.google.com/group/cake-php?hl=.
Thanks to everyone for their input. AD&six's post is indeed comprehensive and I am just picking my through it now. I will post back my final implentation here.
> Nevermind, AD7six post explains it well and very better (and included
> my note, but post alone seems not to be sufficient anyway)
> On Nov 14, 1:27 pm, "j0n4s.h4rtm...@googlemail.com"
> <j0n4s.h4rtm...@googlemail.com> wrote:
>> Another possibility is adding delete links within a <form> that has
>> method = post,
>> check the request method (if its POST) on the action as well.
>> in addition: give that form a class and css stylize it down to a link
>> (though why not keep it a button, buttons = post, links = get paradigm
>> works well too)
>> On Nov 13, 4:55 pm, Jeremy Burns <jeremybu...@me.com> wrote:
>>> On 13 Nov 2009, at 15:44, Marcelo Andrade wrote:
>>>> On Fri, Nov 13, 2009 at 4:14 AM, jburns <jeremybu...@me.com> wrote:
>>>>> I am not happy with the javascript delete confirm method, as it
>>>>> doesn't appear if javascript is disabled and the delete happens with
>>>>> no checking. I want to ask the user to confirm that he wants to delete
>>>>> a record, and would like to do something like this:
>>>>> 1. User clicks a delete link, which points at the delete action.
>>>>> 2. The delete action redirects the user to the view screen for the
>>>>> record with a flash message asking him to confirm the delete, and
>>>>> links to confirm or reject the deletion.
>>>>> 3. If the user clicks the confirm link they are redirected back to the
>>>>> delete action but this time with a parameter that shows the action has
>>>>> been confirmed, and the deletion takes place.
>>>>> 4. The parameter identified in (3) is not present in stage (2), which
>>>>> is how (2) knows to direct to the view screen and ask for
>>>>> confirmation, rather than just processing the delete.
>>>>> 5. I am reusing the view screen and action in (2) so that I don't have
>>>>> to build new confirm_delete screens and actions (I would need to build
>>>>> about 60 of them).
>>>> It's not so hard to do it with ordinary $html->link.
>>>> Point the delete link to a question action that do what
>>>> you want (a link to the real delete action and another
>>>> to go back).
>>>> If you can realize how to do it this way, so you could
>>>> encapsulate the all stuff creating your own helper,
>>>> overriding the $html->link method.
>>>> Best regards.
>>>> --
>>>> MARCELO DE F. ANDRADE
>>>> Belem, PA, Amazonia, Brazil
>>>> Linux User #221105
>>>> --
>>>> 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 athttp://groups.google.com/group/cake-php?hl=.
> --
> 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=.
I am trying to apply this to my site but whenever I access my 'delete' action (I have removed references to 'admin_' in the sample code as I am not using admin_delete yet) I get the error message "The view for XXXController::delete() was not found" (where XXX is my controller). The controller doesn't have a 'delete' function in it as I am using the generic delete function in the app_controller. What am I doing wrong?
> function delete($id) {
> if (!$this->data) {
> $this->set('referer', $this->referer()); // pick this up in the
> view, and add it to the form
> return $this->render('/elements/confirm_delete');
> }
> ... actually delete ..
> $this->redirect($this->data[$this->modelAlias]['referer']); // where
> they came from
> }
> hth,
> AD
> --
> 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=.
> I am trying to apply this to my site but whenever I access my 'delete' action (I have removed references to 'admin_' in the sample code as I am not using admin_delete yet) I get the error message "The view for XXXController::delete() was not found" (where XXX is my controller). The controller doesn't have a 'delete' function in it as I am using the generic delete function in the app_controller. What am I doing wrong?
> Jeremy Burns
> On 13 Nov 2009, at 15:44, AD7six wrote:
> > On 13 nov, 16:30, jburns <jeremybu...@me.com> wrote:
> >> No responses on this - any takers?
> > function delete($id) {
> > if (!$this->data) {
> > $this->set('referer', $this->referer()); // pick this up in the
> > view, and add it to the form
> > return $this->render('/elements/confirm_delete');
> > }
> > ... actually delete ..
> > $this->redirect($this->data[$this->modelAlias]['referer']); // where
> > they came from
> > }
> > hth,
> > AD
> > --
> > 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 athttp://groups.google.com/group/cake-php?hl=.
I know this sounds basic but it was a mistake I've made before. Make
sure you got the spelling right and make sure you don't have the
function defined in another function. I once accidentally wrote my
isAuthoized() inside of another function (I got lost in curly braces)
and hit the same issue.
@AD7six - I went through your tutorial and was wondering if the
SecurityComponent handled protection against CSRF? I'm using
requireAuth and requirePost to address CSRF.
On Nov 18, 1:11 pm, jburns <jeremybu...@me.com> wrote:
> On Nov 17, 6:25 am, Jeremy Burns <jeremybu...@me.com> wrote:
> > I am trying to apply this to my site but whenever I access my 'delete' action (I have removed references to 'admin_' in the sample code as I am not using admin_delete yet) I get the error message "The view for XXXController::delete() was not found" (where XXX is my controller). The controller doesn't have a 'delete' function in it as I am using the generic delete function in the app_controller. What am I doing wrong?
> > Jeremy Burns
> > On 13 Nov 2009, at 15:44, AD7six wrote:
> > > On 13 nov, 16:30, jburns <jeremybu...@me.com> wrote:
> > >> No responses on this - any takers?
> > > function delete($id) {
> > > if (!$this->data) {
> > > $this->set('referer', $this->referer()); // pick this up in the
> > > view, and add it to the form
> > > return $this->render('/elements/confirm_delete');
> > > }
> > > ... actually delete ..
> > > $this->redirect($this->data[$this->modelAlias]['referer']); // where
> > > they came from
> > > }
> > > hth,
> > > AD
> > > --
> > > 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 athttp://groups.google.com/group/cake-php?hl=.
@Amit: requireAuth and requirePost are part of the security component...
@jburns: I have never tried to call a function from app_controller. You can
try placing a function like this in your controller which you are trying to
delete from.
}
On Wed, Nov 18, 2009 at 2:50 PM, Amit <a...@amitvaria.com> wrote:
> I know this sounds basic but it was a mistake I've made before. Make
> sure you got the spelling right and make sure you don't have the
> function defined in another function. I once accidentally wrote my
> isAuthoized() inside of another function (I got lost in curly braces)
> and hit the same issue.
> @AD7six - I went through your tutorial and was wondering if the
> SecurityComponent handled protection against CSRF? I'm using
> requireAuth and requirePost to address CSRF.
> On Nov 18, 1:11 pm, jburns <jeremybu...@me.com> wrote:
> > Any takers on this please?
> > On Nov 17, 6:25 am, Jeremy Burns <jeremybu...@me.com> wrote:
> > > I am trying to apply this to my site but whenever I access my 'delete'
> action (I have removed references to 'admin_' in the sample code as I am not
> using admin_delete yet) I get the error message "The view for
> XXXController::delete() was not found" (where XXX is my controller). The
> controller doesn't have a 'delete' function in it as I am using the generic
> delete function in the app_controller. What am I doing wrong?
> > > Jeremy Burns
> > > On 13 Nov 2009, at 15:44, AD7six wrote:
> > > > On 13 nov, 16:30, jburns <jeremybu...@me.com> wrote:
> > > >> No responses on this - any takers?
> > > > Try this for background:http://www.ad7six.com/e/67 > > > > This (the component is in the mi_plugin branch) for a ~pnp solution,
> > > > but probably a bit too integrated/dependent:
> > > > function delete($id) {
> > > > if (!$this->data) {
> > > > $this->set('referer', $this->referer()); // pick this up in the
> > > > view, and add it to the form
> > > > return $this->render('/elements/confirm_delete');
> > > > }
> > > > ... actually delete ..
> > > > $this->redirect($this->data[$this->modelAlias]['referer']); // where
> > > > they came from
> > > > }
> > > > hth,
> > > > AD
> > > > --
> > > > 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<cake-php%2Bunsubscribe@googlegroups.c om>
> .
> > > > For more options, visit this group athttp://
> groups.google.com/group/cake-php?hl=.
> --
> 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<cake-php%2Bunsubscribe@googlegroups.c om>
> .
> For more options, visit this group at
> http://groups.google.com/group/cake-php?hl=en.
> I know this sounds basic but it was a mistake I've made before. Make
> sure you got the spelling right and make sure you don't have the
> function defined in another function. I once accidentally wrote my
> isAuthoized() inside of another function (I got lost in curly braces)
> and hit the same issue.
> @AD7six - I went through your tutorial and was wondering if the
> SecurityComponent handled protection against CSRF? I'm using
> requireAuth and requirePost to address CSRF.
> On Nov 18, 1:11 pm, jburns <jeremybu...@me.com> wrote:
> > Any takers on this please?
> > On Nov 17, 6:25 am, Jeremy Burns <jeremybu...@me.com> wrote:
> > > I am trying to apply this to my site but whenever I access my 'delete' action (I have removed references to 'admin_' in the sample code as I am not using admin_delete yet) I get the error message "The view for XXXController::delete() was not found" (where XXX is my controller). The controller doesn't have a 'delete' function in it as I am using the genericdeletefunction in the app_controller. What am I doing wrong?
> > > Jeremy Burns
> > > On 13 Nov 2009, at 15:44, AD7six wrote:
> > > > On 13 nov, 16:30, jburns <jeremybu...@me.com> wrote:
> > > >> No responses on this - any takers?
> > > > functiondelete($id) {
> > > > if (!$this->data) {
> > > > $this->set('referer', $this->referer()); // pick this up in the
> > > > view, and add it to the form
> > > > return $this->render('/elements/confirm_delete');
> > > > }
> > > > ... actuallydelete..
> > > > $this->redirect($this->data[$this->modelAlias]['referer']); // where
> > > > they came from
> > > > }
> > > > hth,
> > > > AD
> > > > --
> > > > 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 athttp://groups.google.com/group/cake-php?hl=.
English and literary skills are not what I am grappling with. It is
understanding why it is trying to direct me to the delete view. The
entire message is as I typed - it is being presented in an error view
so there is no more for me to read.
I have removed the delete function from my controllers and added it to
my app_controller:
function delete($id) {
if ($this->{$this->modelClass}->del($id)) {
$this->Session->setFlash($this->modelClass . ' with id ' . $id .
'deleted');
}
This is failing before the delete happens. I just can't track down
where the delete is failing, when the direct is happening and why it
is trying to direct to a delete view. As far as I know you never have
a delete view - the model function does its job and then redirects you
to the view you prescribe in your controller. Just stumped really.
On Nov 25, 12:25 pm, Fran Iglesias <cakephpi...@gmail.com> wrote:
On 25 nov, 13:39, jburns <jeremybu...@me.com> wrote:
> This is failing before the delete happens. I just can't track down
> where the delete is failing, when the direct is happening and why it
> is trying to direct to a delete view. As far as I know you never have
> a delete view - the model function does its job and then redirects you
> to the view you prescribe in your controller. Just stumped really.
I'm confused why after asking "I want to ask the user to confirm that
he wants to delete
a record" you're confused that the solution you're following looks for
a view - the view for the confirmation message & form to present the
user.
I can guess you've copied and pasted the code from the article I
linked to without understanding what it does - it prevents your delete
function from running on a get request - by making use of the security
component's blackhole to prompt the user with a form to confirm
whatever function it is they asked for is really what they want to do.
- The error message tells you /exactly/ where cake is looking for the
view file you directly or indirectly asked to render - and by some
nifty Ctrl+F action in your controller(s) you can find out where in
the code it's triggering that.
Apologies, but I am still struggling with this. I have deployed your
code as is, with the following changes:
I have removed this line:
if (isset($this->params[CAKE_ADMIN]) && !$this->RequestHandler->isAjax
()) {
$this->layout = 'admin';
}
...because it errors and is not relevant to me.
Same with this line:
if ($this->javascripts) {
$this->set('javascripts', $this->javascripts);
}
I am not using admin routing, so have changed references to
admin_delete to delete.
This line errors:
$this->Security->__generateToken($this);
...but works if I change the double underscore to a single underscore.
I have created the _generic folder and put the confirm_action view in
it.
I *think* I understand what is going on in the code. It picks up that
I am calling the delete action via a link (and therefore a GET). As
'delete' is in the $postActions array, I am directed to the
_confirmAction function. This renders the confirm_action view, which
contains a form that calls the delete action via a POST. When I submit
the form it ought to come back into app_controller and pass through to
the delete action. However, I am still being directed back to the
confirm_action view.
Stumped. I notice that it is calling Security->_generateToken. Should
this be being picked up anywhere else? If not, what is its purpose?
I appreciate your help. This is gnawing away at me and I can't work it
through.
Thanks.
On Nov 25, 12:48 pm, AD7six <andydawso...@gmail.com> wrote:
> On 25 nov, 13:39, jburns <jeremybu...@me.com> wrote:
> > This is failing before thedeletehappens. I just can't track down
> > where thedeleteis failing, when the direct is happening and why it
> > is trying to direct to adeleteview. As far as I know you never have
> > adeleteview - the model function does its job and then redirects you
> > to the view you prescribe in your controller. Just stumped really.
> I'm confused why after asking "I want to ask the user toconfirmthat
> he wants todelete
> a record" you're confused that the solution you're following looks for
> a view - the view for the confirmation message & form to present the
> user.
> I can guess you've copied and pasted the code from the article I
> linked to without understanding what it does - it prevents yourdelete
> function from running on a get request - by making use of the security
> component's blackhole to prompt the user with a form toconfirm
> whatever function it is they asked for is really what they want to do.
> - The error message tells you /exactly/ where cake is looking for the
> view file you directly or indirectly asked to render - and by some
> nifty Ctrl+F action in your controller(s) you can find out where in
> the code it's triggering that.
> Apologies, but I am still struggling with this. I have deployed your
> code as is, with the following changes:
> I have removed this line:
> if (isset($this->params[CAKE_ADMIN]) && !$this->RequestHandler->isAjax
> ()) {
> $this->layout = 'admin';
> }
> ...because it errors and is not relevant to me.
> Same with this line:
> if ($this->javascripts) {
> $this->set('javascripts', $this->javascripts);
> }
> I am not using admin routing, so have changed references to
> admin_delete to delete.
> This line errors:
> $this->Security->__generateToken($this);
> ...but works if I change the double underscore to a single underscore.
> I have created the _generic folder and put the confirm_action view in
> it.
> I *think* I understand what is going on in the code. It picks up that
> I am calling the delete action via a link (and therefore a GET). As
> 'delete' is in the $postActions array, I am directed to the
> _confirmAction function. This renders the confirm_action view, which
> contains a form that calls the delete action via a POST. When I submit
> the form it ought to come back into app_controller and pass through to
> the delete action. However, I am still being directed back to the
> confirm_action view.
> Stumped. I notice that it is calling Security->_generateToken. Should
> this be being picked up anywhere else? If not, what is its purpose?
> I appreciate your help. This is gnawing away at me and I can't work it
> through.
> Thanks.
Without seeing your exact code I|other people can't help much.
Yes, the core changed a little in the past 2 years, as did a few other
things. e.g. I personally don't use a _generic folder anymore since
you can just do $this->render('/elements/this_one'); - as can be seen
in the repo solution I linked to.
If you're being redirected to confirm_action in a loop the form token
that's generated 'manually' (see the form helper create function if
you want to see what else uses it) doesn't match what the security
component is expecting. Except for the period of time when I was
originally writing this technique - I haven't seen that happen. You'd
need to debug and find out why.
Thanks for the reply. I guess it is a tad unreasonable to expect two
year old code to 'just work'! I just like stuff out of the box :-)
I'll follow your suggestions and then rather than slavishly try and
make this function I'll branch off my own way until I get something
working. I'll post back my solution here.
On Dec 1, 9:34 am, AD7six <andydawso...@gmail.com> wrote:
> On 27 nov, 12:28, jburns <jeremybu...@me.com> wrote:
> > @AD7Six
> > Apologies, but I am still struggling with this. I have deployed your
> > code as is, with the following changes:
> > I have removed this line:
> > if (isset($this->params[CAKE_ADMIN]) && !$this->RequestHandler->isAjax
> > ()) {
> > $this->layout = 'admin';
> > }
> > ...because it errors and is not relevant to me.
> > Same with this line:
> > if ($this->javascripts) {
> > $this->set('javascripts', $this->javascripts);
> > }
> > I am not using admin routing, so have changed references to
> > admin_delete to delete.
> > This line errors:
> > $this->Security->__generateToken($this);
> > ...but works if I change the double underscore to a single underscore.
> > I have created the _generic folder and put the confirm_action view in
> > it.
> > I *think* I understand what is going on in the code. It picks up that
> > I am calling the delete action via a link (and therefore a GET). As
> > 'delete' is in the $postActions array, I am directed to the
> > _confirmAction function. This renders the confirm_action view, which
> > contains a form that calls the delete action via a POST. When I submit
> > the form it ought to come back into app_controller and pass through to
> > the delete action. However, I am still being directed back to the
> > confirm_action view.
> > Stumped. I notice that it is calling Security->_generateToken. Should
> > this be being picked up anywhere else? If not, what is its purpose?
> > I appreciate your help. This is gnawing away at me and I can't work it
> > through.
> > Thanks.
> Without seeing your exact code I|other people can't help much.
> Yes, the core changed a little in the past 2 years, as did a few other
> things. e.g. I personally don't use a _generic folder anymore since
> you can just do $this->render('/elements/this_one'); - as can be seen
> in the repo solution I linked to.
> If you're being redirected to confirm_action in a loop the form token
> that's generated 'manually' (see the form helper create function if
> you want to see what else uses it) doesn't match what the security
> component is expecting. Except for the period of time when I was
> originally writing this technique - I haven't seen that happen. You'd
> need to debug and find out why.