如果只有1条记录,则将输入/选择更改为隐藏字段

How do i change select to hidden field if it has only 1 record. If only 1 branch i want it to be hidden with that id, as the branch_id, being the value.

View

    echo $this->Form->input('branch_id');

CTRL

    $this->set('branches', $this->Holiday->Branch->find('list'));

You can try this, assuming it returns an array:

if(count($branches) == 1) {
    echo $this->Form->input('branch_id', array('type' => 'hidden', 'value' => $branches['Branch'][0]['branch_id']));
}