Dropdown select list in CakePHP

前端 未结 10 965
一个人的身影
一个人的身影 2020-12-15 11:59

Does anybody know how to select the contents of one take from a different view in CakePHP?

I have a take itemgroups that has 2 fields ID an

10条回答
  •  天命终不由人
    2020-12-15 12:32

    Assuming your model is User and the field you want to use is a list of US states (for example)...

    In your controller:

    $this->set('states',$this->State->find('list'));
    

    and in your view:

    input('User.state',array('type'=>'select','options'=>$states)); ?>
    

提交回复
热议问题