yii - how to generating a dropdown list in yii2 -
I tried to create a dropdown list in yii2 using this link:
My code is :
& lt ;? Php use yii \ helpers \ ArrayHelper; Use the app \ model \ product; ? & Gt; & Lt ;? = $ Listdata = ArrayHelper :: Map (Product :: Search () - & gt; All (), 'id', 'name'); ? & Gt; & Lt ;? = $ Form-> Field ($ model, 'parent_id') - & gt; DropDownList ($ listdata); ? & Gt; But I have a problem using ArrayHelper - The problem is: PHP Notices - yii \ base \ errorException Array for conversion string < / Strong> .......! I have tested the code below:
$ listData = ArrayHelper :: map (Product :: Search () -> asArray () - & gt; all (), 'id' , 'Name'); But this is not the solution and there is only one error!
What is the problem? Can anyone help me?
Are you trying to resize an array, and ? = & lt ;? Php In:
& lt ;? = $ Listdata = ArrayHelper :: Map (Products :: Search () - & gt; All (), 'id', 'name'); ? & Gt;
Comments
Post a Comment