I am new to cakephp and am trying to create a really simple api where the user can 'reserve' a vehicle through an api.
I have three Models, Views and Controllers, which are Vehicles, Customers and Reservations. I have implemented most of it but i am just stuck on how i can add a reservation by allowing the user to pick from a dropdown list.
Basically i want two dropdown lists that allow me to select the customer id/name and vehicle id/name. and put them into the reservations table.
This is my reservations controller add function
function add() {
if($this->request->is('post')) {
if($this->Reservation->save($this->data)) {
$this->Session->setFlash('The Reservation was successfully added!');
$this->redirect(array('action'=>'index'));
} else {
$this->Session->setFlash('The Reservation was not added.');
}
}
$customers = $this->Customers->find('list');
$this->set(compact('customers'));
$this->set('title_for_layout','Add Reservation');
}
At the bottom i have used some code from a different website that should create a list of customers, but i get an error. Also because the customers content is in a different model, im guessing this is the wrong way to go about it.
So how can i add a dropdown list of customers to my reservations page.