0
아래 예제에서 ID 대신 값을 표시하려면 어떻게해야합니까?CakePHP 3 관련 데이터를 형태로 표시
표 문서가 포함되어
이 .ctp에서$test = $this->Documents->find('all',['conditions' => ['review_date'=>date('Y-m-d', strtotime('2022-01-01')) ] ]);
그것을 보여줍니다 (이 중요한 경우)하지 DocumentsController에 ID가, 제목, 몸, person_id로, 나는하지만, 이런 식으로 얻을
을 review_date 같은 :
<tbody>
<?php foreach ($test as $document): ?>
<tr>
<td><?= $document->id; ?></td>
<td><?= $document->person_id; ?></td>
</tr>
<?php endforeach; ?>
</tbody>
그리고 나는을 person_id로 대신 의 사람의 이름을 표시합니다. ...
public function add()
{
$this->loadModel('Documents');
$this->loadModel('Persons');
$this->loadModel('SelfReports');
$this->loadModel('PlannedQuestions');
$agenda = $this->Agendas->newEntity();
if ($this->request->is('post')) {
$agenda = $this->Agendas->patchEntity($agenda, $this->request->getData());
if ($this->Agendas->save($agenda)) {
$this->Flash->success(__('The agenda has been saved.'));
return $this->redirect(['action' => 'index']);
}
$this->Flash->error(__('The agenda could not be saved. Please, try again.'));
}
$per = $this->Persons->find('all');
$tes = $this->Documents->find('all',[
'conditions' => ['review_date'=>date('Y-m-d', strtotime('2022-01-01'))],
'fields' => ['Documents.id','RefArticles.article_number','Persons.name']]);
$selfreports = $this->SelfReports->find('all',['conditions' => ['next_visit_date'=> date('Y-m-d', strtotime('thursday this week'))]]);
$plannedquestions = $this->PlannedQuestions->find('list');
$this->set(compact('agenda', 'tes'));
$this->set('_serialize', ['agenda']);
}