如果只有1条记录,我如何将选择更改为隐藏字段。如果只有一个分支,我希望它与该id一起隐藏,作为branch_id,作为值。
查看
echo $this->Form->input('branch_id');
CTRL
$this->set('branches', $this->Holiday->Branch->find('list'));
答案 0 :(得分:0)
你可以试试这个,假设它返回一个数组:
if(count($branches) == 1) {
echo $this->Form->input('branch_id', array('type' => 'hidden', 'value' => $branches['Branch'][0]['branch_id']));
}