Hi
My dropdown is working but it is displaying all of the attributes returned in the array.
I would like to only set the [id] as the dropdown value & display [player_surname] in the dropdown list but I am unsure how to only get and pass these attributes.
Any help would be most appreciated
Model
// Return a player array for primary use in dropdowns
public function getPlayerlist()
{
$id=(Yii::app()->user->venue_user_id); // set the ID
// Return all the players associated with the users venue
$sqlPlayers='SELECT * FROM player LEFT JOIN player_venues ON player.id = player_venues.player_id WHERE player_venues.venue_id=:id AND player_venues.active = "yes"';
$result = Yii::app()->db->createCommand($sqlPlayers)->bindValue('id',$id)->queryAll();
$playerList = array();
foreach($result as $row)
{
$playerList[ ] = $row;
}
return $playerList; // return the array values into the dropdown
}
Returned Array Values From Model
Array
(
[0] => Array
(
[id] => 1
[player_salutation] => Mr.
[player_forename] => Martin
[player_surname] => Blackshaw
)
[1] => Array
(
[id] => 2
[player_salutation] => Mr.
[player_forename] => David
[player_surname] => Ward
)
[2] => Array
(
[id] => 14
[player_salutation] => Mr.
[player_forename] => Simon
[player_surname] => Walker
)
[3] => Array
(
[id] => 15
[player_salutation] => Mrs.
[player_forename] => Susan
[player_surname] => Potts
)
)
Dropdown In The View File
<?php
echo $form->dropDownList($model, 'player_total_selector', $model->getPlayerlist(),
array(
'class'=>'styled-select',
'prompt'=>'Select Your Player',
));
?>
Many thanks
GPM