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

Reply via email to