나는 CakePHP에서 예약 생성을 위해 3 개의 테이블을 사용하는 간단한 예약 시스템을 구축하고 있습니다. 그들은 클라이언트, 의사 및 약속입니다. 의뢰인과 의사는 복수의 약속을 가질 수 있지만 약속에는 오직 의뢰인과 의사가 하나만있을 수 있습니다.CakePHP는 클라이언트를위한 약속을 만듭니다.
작성하고 편집하는 클라이언트 부품은 훌륭하게 만들었지 만 작성 일정을 작성하고 의사와 클라이언트에 연결하는 데 어려움을 겪고 있습니다. 모델에서 관계를 설정하고 데이터를 가져 오기 위해 잘 작동하므로 의도 한대로 작동합니다. /appointments/add/1
을 다음보기에서이 같은 것입니다 : 당신은 내가 원하는 볼 수 있습니다 그래서
<h1>Book Appointment <em>for</em> <?php echo $client['Client']['firstname'] . " " . $client['Client']['lastname']; ?></h1>
<?php echo $this->Form->create('Appointment', array('url' => array('admin'=>true,'controller'=>'appointments','action'=>'add',$client_id))); ?>
<fieldset id="post-form">
<ul>
<li>
<?php echo $this->Form->input('client_id', array('type' => 'hidden','value'=>$client_id)); ?>
<?php echo $this->Form->input('doctor_id', array('label' => '<strong>Choose Doctor</strong>',$doctors)); ?>
</li>
<li>
<?php echo $this->Form->input('datetime', array('label' => '<strong>Date and Time</strong>')); ?>
</li>
<li>
<?php echo $this->Form->input('treatment', array('label' => '<strong>Treatment</strong>')); ?>
</li>
<li class="sep clearfix">
<input class="submit" type="submit" name="submit" value="Book Appointment" />
</li>
</ul>
</fieldset>
<?php echo $this->Form->end(); ?>
을
그래서 예를 들어 내가 방문 할 하나의 ID와 클라이언트에 대한 약속을 예약하려면 전달 된 ID (약속 표에서 client_id라고 함)를 사용하여 헤더에 클라이언트 이름을 표시합니다. 그리고 드롭 다운에서 의사 이름을 선택할 수 있어야합니다.
이 지금까지 내 컨트롤러 액션은 다음과 같습니다
그러나 의사의 내 목록이 생성되지 않는function admin_add($client_id)
{
$this->set('client_id', $client_id);
$this->set('doctors', $this->Appointment->Doctor->find('list'));
if (!empty($this->data))
{
if ($this->Appointment->save($this->data))
{
$this->Session->setFlash('Your post has been saved.');
$this->redirect(array('admin' => true, 'controller' => 'appointments', 'action' => 'index'));
}
}
}
... 누군가가 도와 드릴까요? 감사합니다
편집 : 또한 양식을 제출할 때마다 1의 ID로 매번 동일한 약속을 무시합니다. 그래서 새로운 약속을 만들지 않습니다 ... 아이디어가 있습니까?
에서 모델 이름을 누락하는 경우
확실하지, 확인을 보인다. 보기에 $ doctors 변수를 디버깅하여 거기에 아무 것도 있는지 확인하십시오. –