I have solved this issue (phew!).

In my edit function I redirect after a successful save. The redirect
command is as generated by Bake:

$this->redirect(array('action' => 'view', $this->Xxxx->id));

You'll notice that the controller is not set. Changing it to:

$this->redirect(array('controller' => 'xxxx', 'action' => 'view',
$this->Xxxx->id));

...solves the issue.

I am surprised that more people don't run into this issue.

On Dec 14, 2:07 pm, Jeremy Burns <[email protected]> wrote:
> I have a problem that is driving me mad! I have a form that submits
> data to an edit action. It works fine when using $form->submit. I want
> to submit the form via Ajax. If I change the form submit button to the
> following:
>
> $ajax->submit (
>         'Save',
>         array(
>                 'div' => false,
>                 'url' => array(
>                         'controller' => 'xxx',
>                         'action' => 'edit',
>                         $id
>                 ),
>         'update' => 'divForm'
>         )
> );
>
> ...I get a stream of errors inside the div 'divForm' along these
> lines:
>
> Notice (8): Undefined index: controller [CORE/cake/dispatcher.php,
> line 411]
>
> Notice (8): Undefined index: controller [CORE/cake/dispatcher.php,
> line 133]
>
> Error:  Controller could not be found.
>
> Error:  Create the class Controller below in file: app/controllers/
> controller.php
>
> <?php
> class Controller extends AppController {
>
>         var $name = '';}
>
> ?>
>
> The errors are being thrown by dispatcher.php when it tries to find
> $this->params['controller']. That index is not in the params array.
>
> Does anyone have any idea what might be going astray here? I have seen
> some references to this issue elsewhere, but I have not located a
> resolution as yet.

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 [email protected]
To unsubscribe from this group, send email to
[email protected] For more options, visit this group at 
http://groups.google.com/group/cake-php?hl=en

Reply via email to