Hi All,
Started my first project with Yii and YiiBooster and have a question regarding dropDownListRow.
In _form.php I have the following:
<?php echo $form->($model, 'NationalityID', $model->getNationalities()); ?>
In the model I have:
public function getNationalities()
{
//$rawData = Nationality::model()->findAll();
$rawData=Yii::app()->db->createCommand('SELECT * FROM tbl_nationality')->queryAll();
$dataProvider = new CArrayDataProvider($rawData, array(
'id'=>'someid',
'keyField' => 'ID',
'sort'=>array(
'attributes'=>array('Nationality'),
),
));
$val = $dataProvider->getData();
return $val;
}
How do I specify the format of the array to return. With the "findAll()" function to populate rawData I get an error, and with the "queryAll()" it works but it returns this array:
Array ( [0] => Array ( [ID] => 1 [Nationality] => Algerian ) [1] => Array ( [ID] => 4 [Nationality] => Belgian ) [2] => Array ( [ID] => 2 [Nationality] => French ) [3] => Array ( [ID] => 3 [Nationality] => Italian ) )
I need some guidance…