Home>

Thank you for watching the question.
The master screen is made with cakephp2.
Copy and paste other master screens and add/correct only the necessary parts.
We were able to pass data from other tables to the view side using file (list) on the control side.
However, it is not clear how to put the data into the select box.

##### View

    <label for = "">Department</label>
    <select name = $sections data-bind = "options: mt_section_id, value: detail.mt_section_id"></select>
##### Control
class MtEmployeesController extends AppController {
    public $uses = array ('MtEmployee', 'MtSections');
    public function index () {
        $this->set ('sections', $this->MtSections->find ('list'));
    }

I tried to put $sections which is arbitrary array data at select name =, but the selection box appeared on the screen, but there was no response even if I clicked it.
Originally single quotes were attached to the data names, so I deleted them.

Supplemental information (FW/tool version etc.)

Because i am a beginner, you don't know right or left.
I think that there are many parts that do not reach, but thanks for your response.

  • Answer # 1

    I don't know the table structure of the department master

    Department ID mt_section_id
    Department name mt_section_name

    Based on the premise of

    , I think you can do the following.

    Form->input ('sections', array ('type' =>'select', 'options' =>$sections))? >
    public function index () {
            $this->set ('sections', $this->MtSections->find ('list', array (
                    'fields' =>array ('mt_section_id', 'mt_section_name')
            )));
        }