我有一个表格,学生可以使用下拉列表输入科目。下拉列表从表中获取主题。我想验证这个下拉列表,以便学生只选择一次主题。主题正在循环播放。我怎样才能做到这一点?
我的控制器
for ($i = 1; $i < sizeof($this->data['ApplicantOlevelQualification']['olevel_subject_code']); $i++) {
if ($this->data['ApplicantOlevelQualification']['olevel_subject_code'][$i] != "") {
$this->ApplicantOlevelQualification->create();
$this->ApplicantOlevelQualification->id = null;
$this->ApplicantOlevelQualification->set(array(
'applicants_detail_id' => $app_id,
'olevel_subject_code' => $this->data['ApplicantOlevelQualification']['olevel_subject_code'][$i],
'grade' => $this->data['ApplicantOlevelQualification']['grade'][$i],
'mark' => $this->data['ApplicantOlevelQualification']['mark'][$i],
'centre_number'=> $centre_number,
'candidate_number'=> $candidate_number,
'exam_body_code'=> $exam_body_code,
'year_written'=> $year_written,
)
);
我的 add.ctp
echo "<tr><td>" . $this->Form->label('Subject: ');
echo "</td><td>";
echo $this->Form->select("ApplicantOlevelQualification.olevel_subject_code.$s",$mySubjects);
echo "</td><td>";
模型
'olevel_subject_code' => array(
'numeric' => array(
'rule' => array('valids'),
),
),