How to group values in an array in cakephp?

前端 未结 2 1838
一整个雨季
一整个雨季 2021-01-27 17:25

I have a list of teamleads in an array and their corresponding team members in another array.
I need to group them in an array such that under each teamleads the correspondi

2条回答
  •  醉梦人生
    2021-01-27 18:26

    Get your arrays as a list:

    $this->set('teams', $this->TeamMembers->find('list'));
    

    Then in the form you can set the options:

    $this->Form->input('team_member', array('options' => $teams));
    

    UPDATE You will require javascript / css to manipulate the select field in order to do what you are asking. None of the tags you currently have set will get an answer you are looking for. This cannot be done with regular HTML / PHP code.

提交回复
热议问题