0
votes

This is my code:

<?= 
    $rates= ApplicantRating::find()->all();     
    $listData= \yii\helpers\ArrayHelper::map($rates,'id','name'); 
    
    echo $form->field($model,'name')->dropDownList($listData,['prompt'=>'Select...']);
?>

I have a:

PHP Notice – yii\base\ErrorException Array to string conversion error

and I cannot understand why. It is highlighting the line $rates= ApplicantRating::find()->all(); as the problem. Any suggestions pls?

Thanks a lot.

2
Use <?php tag instead of echo shortcut. - Teemu

2 Answers

1
votes

You need to change <?= to <?php like follows:

<?php 
    $rates= ApplicantRating::find()->all();     
    $listData= \yii\helpers\ArrayHelper::map($rates,'id','name'); 
    
    echo $form->field($model,'name')->dropDownList($listData,['prompt'=>'Select...']);
?>
1
votes

<?= [sentence here] is the same as <?php echo [sentence here] So, what happens is php tries to echo $rates.