jjzjj

arrayhelper

全部标签

php - Yii2 ArrayHelper::toArray 不能递归工作

Yii2ArrayHelper的辅助方法toArray不转换嵌套对象。这是我的测试代码。publicfunctionactionTest(){$product=\common\models\Product::find()->where(['id'=>5779])->with('firstImage')->one();$product=\yii\helpers\ArrayHelper::toArray($product);print_r($product);}默认情况下启用递归属性。publicstaticarraytoArray($object,$properties=[],$recu

yii2 arrayhelper :: map()显示< optgroup>起源不明

我将ArrayHelper用于下拉列表,如下所示。但是下拉列表显示了“hotel_id'和'room_type”的一个,我不知道从哪里。对此有什么想法吗?模型文件规则:publicfunctionrules(){return[[['hotel_id','room_type','max_persons'],'required'],[['hotel_id','max_persons'],'integer'],[['room_type'],'string','max'=>28],];}表单视图文件:field($model,'hotel_id')->dropDownList([ArrayHelper