I have a function that is used to edit a previously existing userprofile here is the controller
class PeoplesController extends AppController
{
public $name = "peoples";
public $helpers = array('Html', 'form', 'Js');
public $components = array('RequestHandler');
public function viewPerson($id = NULL) {
$this->set('person', $this->people->read(NULL, $id));
}
public function editPerson($id = NULL)
{
if(empty($this->data)) {
$this->data = $this->people->read(NULL, $id);
}
else {
if($this->people->save($this->data)) {
$this->Session-setFlash('The profile has been updated');
$this->redirect(array('action'=>'viewPerson', $id));
}
}
}
}
the view outputs a form prepopulated with the previous data
<h2>Edit Profile</h2>
<?php
echo $this->Form->create('people', array('action'=>'edit'));
echo $this->Form->input('firstName');
echo $this->Form->input('secondName');
echo $this->Form->input('addressOne');
echo $this->Form->input('addressTwo');
echo $this->Form->input('city');
echo $this->Form->input('county');
echo $this->Form->input('country');
echo $this->Form->input('postCode', array(
'label' => 'Zip Code',
));
echo $this->Form->input('dob', array(
'label' => 'Date of birth',
'dateFormat' => 'DMY',
'minYear' => date('Y') - 70,
'maxYear' => date('Y') - 18,
));
echo $this->Form->input('homePhone');
echo $this->Form->input('mobilePhone');
echo $this->Form->input('email', array(
'type' => 'email'
));
$goptions = array(1 => 'Male', 2 => 'Female');
$gattributes = array('legend' => false);
echo $this->Form->radio('gender',
$goptions, $gattributes
);
echo $this->Form->input('weight');
echo $this->Form->input('height');
echo $this->Form->input('referedBy');
echo $this->Form->input('id', array('type'=>'hidden'));
echo $this->Form->end('Edit Profile');
?>
the view seems to work fine @
http://localhost/Cake/peoples/editPerson/2
but when I hit submit the url changes to
http://localhost/Cake/people/edit/2
So I changed
echo $this->Form->create('people', array('action'=>'edit'));
to
echo $this->Form->create('people', array('action'=>'editPerson'));
and I tried changing the first parameter of the create function to peoples but as this refers to the model and not the controller it should be people so i changed it back
the error i get is
Error: PeopleController could not be found.
so it is looking for the wrong controller but I am not sure where that seeking for the controller takes place.
I did use to have the controller class name uncapitalised but I follwed some advice on the conventions and capitalised it but the other previous functions I had still work fine so I dont think that is the problem
any ideas why it is changing the url and looking for the wrong controller?