I want to show a form with CakePHP where users can select an employee. Cake shows the inputfield as "select" which is good. Unfortunately the select input field only shows the id of the employee rather than the prename and lastname.
Model:
Reminder:
worker_id (reference to Worker model)
Worker:
id
prename
lastname
Here is the PHP part:
echo $this->Form->create('Reminder',
array('action' => 'add',
'inputDefaults' => array(
'label' => false,
'div' => false
)
)
);
echo $this->Form->input('worker_id', array('empty' => 'Choose an employee'));
echo $this->Form->button('Save', array('type' => 'submit', 'class' => 'btn btn-green'));
I did not find a way to show the prename and lastname of class Worker but keep the id as option value in the select field.
How can this be done?
Aucun commentaire:
Enregistrer un commentaire