So when the user selects a course from the dropdownlist, the testInput will display the course details of the selected row. Both course_taken and course_details are columns from the same database table.
I am not sure how you want it exactly, but if you want to make form fields that are dependent on each other, then you have to use JS probably.
$js = "
$(\"#contollername-modelattribute\").change(function () {
//DO STUFF HERE WHEN THE DROPDOWN IS CHANGED
var text = $(\"#contollername-modelattribute option:selected\").text();
var val = this.value;
console.log(text);
$(\"#contollername-modelattribute2\").val(text);
});
";
$this->registerJs($js, \yii\web\View::POS_READY, 'my-options');
This piece of code would change your textfield value to be the equal as the selected value in the dropdown.
Be aweare of the javascript DOM addressing.
#contollername-modelattribute
For you it would be #controllername-course_taken or #controllername-course_details etc. where #controllername is the name of the controller processing the current form, without any special characters. Eg.: Your controller is my-courses, then you address it #mycourses-course_taken.
You could use two dropdowns or an array with the descriptions to change the textfield value or you can write a function to AJAX the description with JS whenever the dropdown is changed.