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
Follow the conventions of CakePHP and you won't have this problem.
If you query TeamLead->find() and TeamLead hasAndBelongsToMany or hasMany TeamMember the returned array structure will contain everything you need and in a fashion you can use with the FormHelper methods in the views.
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.