I got 2 related tables, let say :
- employee, and
- family
they are both connected by the employeeID as the primary and foreign key. I believe you all understand this standard condition.
I have already created all the models, controllers and views using the "cake bake".
Everything is okay, until when i want to add new family.
The scenario is listed below :
-- on the front page, all employees are listed, along with their VIEW, EDIT and DELETE button, each.
-- i click the VIEW button on one of the employee, let say employee MAZANDRE with employeeID 123
-- i will see the detail of MAZANDRE
-- below the detail, there is one button to ADD NEW FAMILY.
-- i modified the ADD NEW FAMILY hyperlink into this
<li><?php echo $this->Html->link(__('New Family'), array('controller' => 'families', 'action' => 'add', $employee['Employee']['id'])); ?> </li>
-- then i also modified the add function in FamiliesController like this
public function add($id = null) {
$this->Family->id = $id;
if ($this->request->is('post')) {
$this->Family->create();
if ($this->Family->save($this->request->data)) {
$this->Session->setFlash(__('The Family has been saved'));
$this->redirect(array('action' => 'index'));
} else {
$this->Session->setFlash(__('The Family could not be saved. Please, try again.'));
}
}
$employees = $this->Family->Employee->findById($id);
$this->set(compact('employees'));
}
-- then i click this ADD NEW FAMILY button
-- there is one dropdown box which list ALL the employee detail (id, name, dateofbirth, gender etc).
the link shows http://x.x.x.x/hr/family/add/123
what i want is, the INPUTBOX should only list one name which is: MAZANDRE, and cannot be modified (disabled)
the original one is like this echo $this->Form->input('employee_id')
how should i do this ?
Appreciate your help guys :-)
Many thanks.
Regards,
Andri