Storing Values in Dropdown

I have 2 modules which is Service Reports and Request.

The Service Request has a column name which is ID it is auto incremented whenever I post something. How am I going to make the ID value on service request show on a specific dropdown in the reports form.

Let’s assume your Service Request model is ServiceRequest, Service Report model is ServiceReport, and ServiceReport model has a field request_id which is a relation field between ServiceRequest and ServiceReport models

In the _form.php view of a Service Rerort controller try something like this:




<?= $form->field($model, 'request_id')->dropDownList(\yii\helpers\ArrayHelper::map(ServiceRequest::find()->all(), 'id', 'id')) ?>