I may be wrong in this, but im pretty sure the requirePost() is only supposed to be used once. It should only be used on the initial request of the page, not subsequently after.
Why would you have that page require a post to access? And not just turn it back to a link? It doesn't solve any problems, it just adds more complexity to it. The only time requirePost() is a great idea, is when doing a delete (/ products/delete/1), where that page must be hit with a post. Once hit with a post, it does the delete logic and redirects or flashes. On Jan 20, 9:54 am, DaveTheRave <dr-s...@hotmail.com> wrote: > I have a test CakePHP Application that lists various products on a > single page called "views/products/index.ctp". > To start with each product had an "Edit" link that targeted action > "products/edit/<productid>". > > This worked fine. > I then added "$this->Security->requirePost('edit');". > I replaced the link on "index.ctp" page with a form defined as > follows... > > WAS... > echo $html->link(__('Edit', true), '/products/edit/'.$this->data > ['Product']['id']); > > NOW... > echo $form->create('Product', array('action'=>'edit/'.$this->data > ['Product']['id'])); > echo $form->submit(__('Edit', true)); > echo $form->end(); > > The "Edit" page again uses the $form helper to create a form with a > post action for posting back the changes to "$this->data" and uses the > syntax shown below. > echo $form->create('Product', array('action'=>'edit/'.$this->data > ['Product']['id'])); > echo $form->input('title'); > ..... > echo $form->end(__('Submit', true)); > > When I click the "Edit" button it does take me to the "Edit" page. > The URL now shows the action path .../products/edit/<productid>. > After making changes I press the Submit button on the "Edit" page, but > I get sent to the blackHoleCallback. > > When "requirePost" is removed, everything works fine! > > I should point out that a Token is being created by the > "SecurityComponent" and is held in "$this->data". > As a result I have had to change the checks within the "Edit" action > in the controller so that they check for "$this->data['Product']" > being empty rather than just "$this->data". > > Can anyone tell me how I should have done this? > > Thanks, > DaveTheRave
Check out the new CakePHP Questions site http://cakeqs.org and help others with their CakePHP related questions. 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+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/cake-php?hl=en