Replace id colum in drop-down by name column

after using: bin \ cake bake all name_table1 and bin \ cake bake all name_table2, i have a drop-down list with the id of my table1 in the view of table 2. I would like to display the column name 1 instead of id 1 in the drop-down list, but when I save that I memorize the id.
I use cakephp 3.

villeController :
`

<?php namespace App\Controller; use App\Controller\AppController; /** * Ville Controller * * @property \App\Model\Table\VilleTable $Ville * * @method \App\Model\Entity\Ville[]|\Cake\Datasource\ResultSetInterface paginate($object = null, array $settings = []) */ class VilleController extends AppController { /** * Index method * * @return \Cake\Http\Response|void */ public function index() { $ville = $this->paginate($this->Ville); $this->set(compact('ville')); } /** * View method * * @param string|null $id Ville id. * @return \Cake\Http\Response|void * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function view($id = null) { $ville = $this->Ville->get($id, [ 'contain' => [] ]); $this->set('ville', $ville); } /** * Add method * * @return \Cake\Http\Response|null Redirects on successful add, renders view otherwise. */ public function add() { $ville = $this->Ville->newEntity(); if ($this->request->is('post')) { $ville = $this->Ville->patchEntity($ville, $this->request->getData()); if ($this->Ville->save($ville)) { $this->Flash->success(__('Sauvegardé')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('Echec, veuillez essayer encore !')); } $this->set(compact('ville')); } /** * Edit method * * @param string|null $id Ville id. * @return \Cake\Http\Response|null Redirects on successful edit, renders view otherwise. * @throws \Cake\Network\Exception\NotFoundException When record not found. */ public function edit($id = null) { $ville = $this->Ville->get($id, [ 'contain' => [] ]); if ($this->request->is(['patch', 'post', 'put'])) { $ville = $this->Ville->patchEntity($ville, $this->request->getData()); if ($this->Ville->save($ville)) { $this->Flash->success(__('The ville has been saved.')); return $this->redirect(['action' => 'index']); } $this->Flash->error(__('Echec, veuillez essayer encore !')); } $this->set(compact('ville')); } /** * Delete method * * @param string|null $id Ville id. * @return \Cake\Http\Response|null Redirects to index. * @throws \Cake\Datasource\Exception\RecordNotFoundException When record not found. */ public function delete($id = null) { $this->request->allowMethod(['post', 'delete']); $ville = $this->Ville->get($id); if ($this->Ville->delete($ville)) { $this->Flash->success(__('Sauvegardé')); } else { $this->Flash->error(__('Echec, veuillez essayer encore !')); } return $this->redirect(['action' => 'index']); } /** * export method * exporter en fichier excel * */ public function exporteData() { $datatable = ''; $datatable = ''; $datatable .= ''; $ville = $this->Ville->find('all')->toArray(); foreach ($ville as $ville) { $id_ville = $ville['id_perso']; $nom = $ville['nom']; $codePostal = $ville['codePostal']; $datatable .= ''; } $datatable .= "
S.No NOM CODE POSTAL
'. $id_ville. ' '. $nom. ' '. $codePostal. '
"; header('Content-Type: application/force-download'); header('Content-disposition: attachemnt; filename= liste_des_villes_p1App.xls'); header("Pragma: "); header("Cache-Control: "); echo $datatable; die; } } ` **add.ctp:** ` <?php /** * @var \App\View\AppView $this * @var \App\Model\Entity\Ville $ville */ ?>
  • <?= __('Actions') ?>
  • <?= $this->Html->link(__('Liste des Villes'), ['action' => 'index']) ?>
<?= $this->Form->create($ville) ?> <?= __('Nouvelle Ville') ?> <?php echo $this->Form->control('id_dept'); echo $this->Form->control('nom'); echo $this->Form->control('codePostal');
    ?>
</fieldset>
<?= $this->Form->button(__('Valider')) ?>
<?= $this->Form->end() ?>
`

view.ctp
`

<?php /** * @var \App\View\AppView $this * @var \App\Model\Entity\Ville $ville */ ?>
  • <?= __('Actions') ?>
  • <?= $this->Html->link(__('Modification'), ['action' => 'edit', $ville->id_ville]) ?>
  • <?= $this->Form->postLink(__('Suppression'), ['action' => 'delete', $ville->id_ville], ['confirm' => __('Voulez-vous vraiment supprimer ?')]) ?>
  • <?= $this->Html->link(__('Liste des Villes'), ['action' => 'index']) ?>
  • <?= $this->Html->link(__('Nouvelle Ville'), ['action' => 'add']) ?>
<?= __('Id Dept') ?> <?= $this->Number->format($ville->id_dept) ?>
<?= __('Nom') ?> <?= h($ville->nom) ?>
<?= __('CodePostal') ?> <?= $this->Number->format($ville->codePostal) ?>

`
Picture :
img