1
votes

I have a CakePHP 2.3 setup with the following route:

Router::connect('/contact', array('controller' => 'old_layout', 'action' => 'contact'));

In my AppController, I define

public $components = array(
    'Security'...
);

In OldLayoutController, in the beforeFilter() function I define:

$this->Security->allowedControllers = array('OldLayout');

In the view for old_layout/contact, I generate the form using the Form->create() and end() functions and regular Form::input()... commands.

When I submit the form at /contact, I get the following message:

The request has been black-holed
Error: The requested address '/[domain].com/contact' was not found on this server.

Thing is, I do the exact same thing for another form in a different controller which works perfectly.

1
might be obvious but is there a contact action defined on the OldLayout controller? - Orangepill
of course, and its fully implemented, unit tested, and working. I was adding this security stuff after the fact. Which reminds me, my unit tests (which take into consideration this security) work just fine. - Derek
I've narrowed it down to the fact that the token and the generated check inside SecurityComponent::_validatePost() don't match. It's strange though because even after modifying both the form (using $this->Form->unlockField()...), and the list of SecurityComponent::unlockedFields() to ignore the correct set of form elements, it still generates a different $check token. - Derek
After much debugging, I figured it out. It was all due to an errant 'reset' button that was being generated incorrectly. - Derek
@Derek You might want to answer your own question and mark that answer as "solution" so that we know it has been solved :) Wasted a few minutes of my precious time :D - Jelmer

1 Answers

0
votes

After much debugging, I figured it out. It was all due to an errant 'reset' button that was being generated incorrectly.