php - change input/select to hidden field if only 1 record -


how change select hidden field if has 1 record. if 1 branch want hidden id, branch_id, being value.

view

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

ctrl

    $this->set('branches', $this->holiday->branch->find('list')); 

you can try this, assuming returns array:

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

Comments

Popular posts from this blog

PHP DOM loadHTML() method unusual warning -

python - How to create jsonb index using GIN on SQLAlchemy? -

c# - TransactionScope not rolling back although no complete() is called -