In my form I have the category_id, In the drop-down, it displays the name but after saving it displays the ID, how do I display the name instead of the ID?
<?= $form->field($model, 'category_id')->dropDownlist(
ArrayHelper::map(Category::find()->all(), 'id', 'category_name'),
[
'prompt' => 'Select Category',
'onchange' => '$.post( "index.php?r=sub-cat/lists&id='.'"+$(this).val(), function( data ) {
$( "select#tickets-sub_category" ).html( data );
});'
]);
?>
What I have tried so far in the view is this:
[
'label' => $model->category_id->getAttributeLabel('category_name'),
'value' => $model->category_id->category_name
]
But I'm getting an error: Call to a member function getAttributeLabel() on integer