Changes
Title
unchanged
Relational data fields display and edit with the yii2-detail-view extension
Category
unchanged
Tutorials
Yii version
unchanged
Tags
unchanged
yii2, detail, detail-view, yii2-detail-view, DetailView, kartik, kartik-v, relational, attribute, relation, invalid, property, string, array, view, edit
Content
changed
[...]
'data'=>ArrayHelper::map(Author::find()->orderBy('name')->asArray()->all(), 'id', 'name'),
]
]
```
Now that should resolve both the VIEW and EDIT issues for you. With the above configuration, users would still see the author `name` instead of `author_id` in both VIEW and EDIT modes. In the EDIT mode, the above configuration will internally use the `author_id` to save data, but display the author names as a dropdown list using the `\kartik\widgets\Select2` widget.