Dropdown select list in CakePHP

前端 未结 10 950
一个人的身影
一个人的身影 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:38

    You can use like this in your controller and view...

    //In Controller:
        $data=$this->Model->find('list',array('conditions'=>array()));
        $this->set('data',$data);
    
    //In View:
    
        echo $this->Form->select('field_name',$data,null,array("escape"=>false,"empty"=>"select"));
    

    If you want to show initially select value in dropdown then you can pass value where use null in above line.

提交回复
热议问题